04-29-2010 12:26 AM
Yes, I really like the example you found. There is basically no way for a repeat.
That really helps a ton. I was trying to do something crazy with replacing subsets. I had no clue that the first element in a cluster was like a tag.
04-29-2010 12:45 AM
Chod wrote:Yes, I really like the example you found. There is basically no way for a repeat.
That really helps a ton. I was trying to do something crazy with replacing subsets. I had no clue that the first element in a cluster was like a tag.
There is no way for a repeat with either my method or the method I found. Either way, you always start with an ordered array that you predefined that has no repeats in it.
With my method, you are just coming up with random indices to swap the values between. Still no repeats in your data array. You don't change the numbers you have stored in the array, you just go through a process of reordering them. But you have to define a number of times you want to swap (and have that be a function of the size of the array) to try to approach a good randomness to the rearranged data.
With the linked example, same thing, only you are using a finer resolution of the random number generator to reorder things in one pass. There could be a slight flaw in that method. If two original numbers just happen to get assigned the exact same random number down to the last bit of the 32 bit random number, then the number that was to the front of the original array will wind up staying to the front in the final resorted array. But the chances of any 2 values getting exactly the same random number out of 32 bits is pretty unlikely that you would never notice any real bias in the algorithm.
If this was my problem I needed to code, I would use the linked example.
04-29-2010 01:05 AM