Skip to content

Random has strange behavior #56

@sylvainhalle

Description

@sylvainhalle

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions