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

Improve Fisher-Yates random distribution #427

Closed
tarakby opened this issue May 7, 2024 · 1 comment
Closed

Improve Fisher-Yates random distribution #427

tarakby opened this issue May 7, 2024 · 1 comment
Assignees

Comments

@tarakby
Copy link
Contributor

tarakby commented May 7, 2024

Problem

Fisher-yates randomness relies on the sampling of a random number modulo a moduli. Distribution of the output permutation depends on the distribution of the integer sampling.
Cadence v1 offers a uniformly distributed random function revertibleRandom(modulo) that should be used instead of the modulo operator % to avoid the known modulo bias.

Current implementation is

var randomIndex = randomNum % UInt64(i + 1)

@tarakby tarakby added bug Something isn't working Feedback Improvement and removed bug Something isn't working Feedback labels May 7, 2024
@tarakby tarakby self-assigned this May 7, 2024
@tarakby
Copy link
Contributor Author

tarakby commented May 13, 2024

Closed by #428

@tarakby tarakby closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant