you have to be careful with how a shuffle is done - not all of them will produce an uniform distribution of outcomes - with the even/odd done separately and then shuffled gain later, I don't know what the resultant distribution is, but I don't think it's uniform |
In reality, I only proved that shuffling a matrix over its individual dimensions produces no fewer permutations than shuffling a vector; I said nothing about the probability of reaching each permutation.
However, it's not hard to see that the uniformities of S and S
2 are linked. If S is uniform, so is S
2. If S is biased, S
2 is quadratically so.
As long as you've designed the shuffler well, there should be no problem.
Suppose I need 16GB of RAM to run the entire shuffle, but I only have 4GB of real RAM. How will using memory-mapped files help me? |
Consider how you access the array using a linear shuffle. There's a pointer that's always advancing in one direction and the elements on one side of it are never accessed again, while there's another pointer moving at random over the entire space.
If you try to put the array in memory, the OS will constantly attempt to have as much of it as possible in physical memory. You'll end up with thousands of pages in memory that were accessed only once and are then swapped out to make room for a new random portion of the array. You'll only see a speed up when the array is over 75% shuffled, because that portion fits completely in memory.
Conversely, the system is more conservative with its caching when using files. It will only cache if it can afford to do so without swapping out much of the memory of the other running processes. The system as a whole will behave better.
I don't think a memory-mapped file will be faster; in fact, it'll probably be a bit slower because the other method will see a huge speed up once it can fit the whole array in memory. But it will a) share resources better with the rest of the system and b) save you the trouble of writing the array to disk once you're done (I'm assuming you do want to do that).
Both runtime and space are linear. So you are always going to be struggling with space. If not struggling with space, then the `reasonable' average I've always used is about 10^8 operations per second, so you're not going to be struggling with time. |
What do you mean by "reasonable average" and "operation"? There'll be a lot I/O involved, so it's not exactly clear how fast it'll be.
Also, what does space have to do with this? Of course space is an issue. Concurrency doesn't attempt to solve that.