Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuffling is biased #284

Closed
phipsgabler opened this issue Jun 7, 2020 · 0 comments · Fixed by #492
Closed

Shuffling is biased #284

phipsgabler opened this issue Jun 7, 2020 · 0 comments · Fixed by #492

Comments

@phipsgabler
Copy link

phipsgabler commented Jun 7, 2020

I don't even use JS, but stumbled onto your site by chance and find it rather nice.

Anyway, the second proposed snipped for shuffling,

const shuffle = arr => arr.sort(() => .5 - Math.random());

is exactly what one should not do for unbiased permutations, see https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Sorting. (The first should be fine, though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant