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

Slightly better random generation for reservoir sampling #96

Merged
merged 1 commit into from
Oct 24, 2011
Merged

Slightly better random generation for reservoir sampling #96

merged 1 commit into from
Oct 24, 2011

Conversation

jcdavis
Copy link
Contributor

@jcdavis jcdavis commented Oct 23, 2011

nextLong() % n Is ever so slightly not uniform since 2^63 is generally not a multiple of n. Truthfully you would need 10+ million calls to even get a tiny change of seeing nextLong() return a number in "unfair range" (i.e. above Long.MAX_VALUE-Long.MAX_VALUE%n), but even if it doesn't happen the only cost is the extra function call

codahale added a commit that referenced this pull request Oct 24, 2011
Slightly better random generation for reservoir sampling
@codahale codahale merged commit 314b4f9 into dropwizard:development Oct 24, 2011
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 this pull request may close these issues.

None yet

2 participants