RNG-174: Improve support for non-zero seeds

Allow specification of a range for array seeds that must be non-zero.

The values for the range are based on the result of
o.a.c.rng.simple.ProvidersCommonParametricTest.testZeroIntArraySeed.

See also the core module for tests using:
- RandomAssert.assertNextIntZeroOutput
- RandomAssert.assertIntArrayConstructorWithSingleBitInPoolIsFunctional

Any generator that fails these tests requires a non-zero seed. In most
cases this was set as the full seed length, or one less for generators
that do not use all the bits of the seed array (WELL_19937_x,
WELL_44497_x).

Notable exceptions:

The KISS generator is reduced to a simple LCG when positions [0, 3) are
all zero. Added a test to demonstrate this. With a zero seed the KISS
LCG passes testZeroIntArraySeed. To avoid a poor generator the seed will
be checked to be non-zero in [0, 3).

The MSWS generator is sensitive to the initial state. Added a test to
show that a zero seed creates zero output. Updating RandomAssert to add
an assertLongArrayConstructorWithSingleBitInPoolIsFunctional test shows
the MSWS fails with single bit seeds. The sub-range has been set to [2,
3) to ensure a non-zero Weyl increment which is the best way to escape a
bad seed. This is a functionally breaking change.
14 files changed
tree: 4e42a64b819d8ef6185d762db6b458f291c6dc9b
  1. commons-rng-client-api/
  2. commons-rng-core/
  3. commons-rng-examples/
  4. commons-rng-sampling/
  5. commons-rng-simple/
  6. dist-archive/
  7. doc/
  8. docs-archive/
  9. siteMods/
  10. src/
  11. .asf.yaml
  12. .gitattributes
  13. .gitignore
  14. .travis.yml
  15. CONTRIBUTING.md
  16. LICENSE
  17. NOTICE
  18. pom.xml
  19. README.md
  20. RELEASE-NOTES.txt
  21. SECURITY.md
README.md

Apache Commons RNG

Build Status Coverage Status Quality Gate Status Maven Central Javadocs Code Quality: Java

The Apache Commons RNG project provides pure-Java implementation of pseudo-random generators.

Documentation

More information can be found on the Apache Commons RNG homepage. The Javadoc for each of the modules can be browsed:

Questions related to the usage of Apache Commons RNG should be posted to the user mailing list.

Where can I get the latest release?

You can download source and binaries from our download page.

Alternatively you can pull it from the central Maven repositories, e.g.:

<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-rng-simple</artifactId>
  <version>1.4</version>
</dependency>
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-rng-sampling</artifactId>
  <version>1.4</version>
</dependency>

Contributing

We accept Pull Requests via GitHub. The developer mailing list is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us:

  • No tabs! Please use spaces for indentation.
  • Respect the code style.
  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
  • Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running mvn clean test.

If you plan to contribute on a regular basis, please consider filing a contributor license agreement. You can learn more about contributing via GitHub in our contribution guidelines.

License

This code is under the Apache Licence v2.

See the NOTICE file for required notices and attributions.

Donations

You like Apache Commons RNG? Then donate back to the ASF to support the development.

Additional Resources