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

integer generator is noticeably biased away from the ends of the range #88

Open
robinmessage opened this issue Apr 10, 2019 · 0 comments

Comments

@robinmessage
Copy link

The casual.integer generator is noticeably biased away from the ends of the range; the start and end of the range only occur with half the frequency of the other elements.

The reason for this is the use of Math.round and a range of to-from, which is not big enough. A better formula might be:

Math.floor(from (to - from 1) * this.random)

Of course, this would break anyone who is depending on the same answers with the same seed, so maybe a new method would be better?

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

No branches or pull requests

1 participant