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

Random has strange behavior #56

Open
sylvainhalle opened this issue Oct 9, 2021 · 0 comments
Open

Random has strange behavior #56

sylvainhalle opened this issue Oct 9, 2021 · 0 comments

Comments

@sylvainhalle
Copy link
Contributor

sylvainhalle commented Oct 9, 2021

The class ca.uqac.lif.synthia.random.generators.Random has very predictable behavior depending on its seed. Consider:

Random r = new Random();
r.setSeed(X);
System.out.println(r.nextInt(4));

This code prints:

  • 1 if X is in [0,4]
  • 2 if X is in [5,255] U [320,383] U [512,1000]
  • 3 if X is in [256,299] U [302,319]

In other words, large ranges of successive seeds produce the same first number, and in the first 1,000 seeds, 2 is over-represented (it is the first number about 800 times).

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