My main problem with it is that it performs much like Python's itertools, and several other attempts I've made at dealing with large-scale permutations. Even if it (my version) flawed and generates duplicates, this is something I could hash out later down the line. James south - I'm not entirely concerned with my flawed implementation of that article's algorithm, since it does seem to generate the expected count of permutations at lower levels. I'm really just not sure what the best approach is, so I'm looking for wisdom. I'd be okay with that, as long as the possibility for all data still exists in fair probability. 5 random permutations of the current sample set. I don't really need all of the data all of the time, so if it's easier or smarter to only return say. It's a learning experience and that wouldn't be any fun. Once I'm done using the data, be able to generate more using the same function, and the last index of the previously returned list.Įverything else I'm doing with the data I can handle on my own (I think, haha), so I'm not really looking for anyone to write the code for me.Return the list of 5 permutations ( the seed permutation in index 0, like the above list ).(0, 1, 2, 3) would generate and so on to however many permutations are requested) These can be any random permutation of 4 items out of the 9, but would be better if they were sequential permutations based on the input (i.e.Use it as a seed to generate 4 permutations.Take a sample (let's say the first 4) of the 9.return a list of tuples containing each permutation.I think a lot of that is my frustration with this one small obstacle and the lack of current and viable information on the subject.Įssentially, what I'd like to be able to do is as follows: I've also read about streams and/or only generating smaller subsets of data, but I'm not sure where to begin and how I would implement it in a way that none of the data gets lost or duplicated. I've read about a few things that I don't fully grasp like using a generator approach, but I wasn't able to find any implementations that were explained well enough for me to write my own. I don't have a ton of experience programming, and I'm still fairly new to Python, but I'm not afraid to get my hands dirty with some solid information that might help this out. So, I figured I'd ask the great people here for a bit of guidance, some tips, or any resources you guys can think of to help me along my way. I've tried a few different approaches (Itertools, custom built factorials, things I've stumbled on during exhausting searches online) and, while I've had limited success with some approaches I've tried, I seem to hit a bit of a roadblock once the permutation count climbs. I've been trying to wrap my head around dealing with permutations with Python for a little while, but I think I'm going about it all wrong.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |