hxrandom
hxrandom copied to clipboard
Use the actual Fisher-Yates shuffle.
Your implementation does technically show up on the Wikipedia page, but unfortunately, it shows up under "implementation errors":
always selecting j from the entire range of valid array indices on every iteration also produces a result which is biased, albeit less obviously so.
I've modified it to match the second example listed under "the modern algorithm."
Actually, roobie linked to a better explanation of what's wrong.
Hey, I just noticed this hasn't been merged yet. Why not?