hxrandom icon indicating copy to clipboard operation
hxrandom copied to clipboard

Use the actual Fisher-Yates shuffle.

Open player-03 opened this issue 6 years ago • 2 comments

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."

player-03 avatar Nov 18 '18 07:11 player-03

Actually, roobie linked to a better explanation of what's wrong.

player-03 avatar Nov 18 '18 07:11 player-03

Hey, I just noticed this hasn't been merged yet. Why not?

player-03 avatar May 26 '20 17:05 player-03