You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/09/16 18:59:08 UTC

[commons-rng] 12/13: Assert the self-seeded generator output.

This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git

commit bfd5e97dfa5ac0b6a0ddc788990e80a32c7136bd
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Sat Sep 14 20:13:38 2019 +0100

    Assert the self-seeded generator output.
---
 .../core/source32/MiddleSquareWeylSequenceTest.java    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/commons-rng-core/src/test/java/org/apache/commons/rng/core/source32/MiddleSquareWeylSequenceTest.java b/commons-rng-core/src/test/java/org/apache/commons/rng/core/source32/MiddleSquareWeylSequenceTest.java
index e9cde90..8168c15 100644
--- a/commons-rng-core/src/test/java/org/apache/commons/rng/core/source32/MiddleSquareWeylSequenceTest.java
+++ b/commons-rng-core/src/test/java/org/apache/commons/rng/core/source32/MiddleSquareWeylSequenceTest.java
@@ -68,17 +68,23 @@ public class MiddleSquareWeylSequenceTest {
     }
 
     /**
-     * Test the self-seeding functionality. The seeding of the generator requires a high complexity
+     * Test the self-seeding functionality does not throw.
+     *
+     * <p><strong>Warning:</strong> The seeding of the generator requires a high complexity
      * increment for the Weyl sequence. The standard test for the statistical quality of the
      * generator uses a good increment. This test ensures the generator can be created with a seed
-     * smaller than the seed size without exception; the statistical quality of the output is not
-     * assessed and expected to be poor.
+     * smaller than the seed size without exception; the statistical quality of the output from
+     * low complexity Weyl increments is expected to be poor. In this case the output is
+     * non-functional for a large number of cycles.</p>
      */
     @Test
     public void testSelfSeeding() {
-        // Ensure this does not throw. The output quality will be poor.
-        final MiddleSquareWeylSequence rng = new MiddleSquareWeylSequence(new long[0]);
-        rng.nextInt();
+        // This test has been verified to fail when cycles = 2^29 (i.e. 1 << 29).
+        // Here the cycles has been lowered to increase speed.
+        // This demonstrates the generator requires a good seed.
+        final int cycles = 100;
+        RandomAssert.assertNextLongZeroOutput(new MiddleSquareWeylSequence(new long[0]),
+                cycles);
     }
 
     /**