Skip to content
New issue

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

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

Already on GitHub? # to your account

Is 'shuffle' uniform across all permutations? #1258

Closed
RalfJung opened this issue Oct 6, 2022 · 2 comments · Fixed by #1259
Closed

Is 'shuffle' uniform across all permutations? #1258

RalfJung opened this issue Oct 6, 2022 · 2 comments · Fixed by #1259

Comments

@RalfJung
Copy link
Contributor

RalfJung commented Oct 6, 2022

The documentation for shuffle does not explicitly state the probability distribution it implements. What I would expect as a result is a permutation chosen uniformly at random from the set of all permutations. Is that what it does?

@dhardy
Copy link
Member

dhardy commented Oct 6, 2022

Yes.

I guess this should be better documented, though there isn't really any other distribution which would make sense (albeit there are likely quite a few shuffle implementations which are mistakenly non-uniform).

@vks
Copy link
Collaborator

vks commented Oct 6, 2022

This also depends on the generator: If the number of permutations is larger than the state can represent, some permutations have zero probability.

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

Successfully merging a pull request may close this issue.

3 participants