http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/LongMixLong.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/LongMixLong.java b/src/main/java/org/apache/commons/math4/rng/internal/util/LongMixLong.java new file mode 100644 index 0000000..12fb59e --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/LongMixLong.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + +import org.apache.commons.math4.rng.internal.source64.SplitMix64; + +/** + * Uses a {@code long} value to seed a {@link SplitMix64} RNG and + * create a {@code long[]} with the requested number of random + * values. + * + * @since 4.0 + */ +public class LongMixLong implements SeedConverter<Long, long[]> { + /** Size of the output array. */ + private final int size; + + /** + * @param size Size of the output array. + */ + public LongMixLong(int size) { + this.size = size; + } + + /** {@inheritDoc} */ + @Override + public long[] convert(Long seed) { + final long[] out = new long[size]; + final SplitMix64 rng = new SplitMix64(seed); + for (int i = 0; i < size; i++) { + out[i] = rng.nextLong(); + } + + return out; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return getClass().getSimpleName() + "(size: " + size + ")"; + } +}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/NoOpConverter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/NoOpConverter.java b/src/main/java/org/apache/commons/math4/rng/internal/util/NoOpConverter.java new file mode 100644 index 0000000..08aee80 --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/NoOpConverter.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + + +/** + * Dummy converter that simply passes on its input. + * It can be useful to avoid "unchecked" compiler warnings. + * + * @param <SEED> Seed type. + * + * @since 4.0 + */ +public class NoOpConverter<SEED> implements SeedConverter<SEED, SEED> { + /** {@inheritDoc} */ + @Override + public SEED convert(SEED seed) { + return seed; + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "Pass-through"; + } +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/NumberFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/NumberFactory.java b/src/main/java/org/apache/commons/math4/rng/internal/util/NumberFactory.java new file mode 100644 index 0000000..befb16c --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/NumberFactory.java @@ -0,0 +1,327 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + +import java.util.Arrays; +import org.apache.commons.math4.exception.DimensionMismatchException; + +/** + * Utility for creating number types from one or two {@code int} values + * or one {@code long} value, or a sequence of bytes. + */ +public final class NumberFactory { + /** See {@link #makeDouble(long)} */ + private static final long DOUBLE_HIGH_BITS = 0x3ffL << 52; + /** See {@link #makeFloat(int)} */ + private static final float FLOAT_MULTIPLIER = 0x1.0p-23f; + /** See {@link #makeDouble(int, int)} */ + private static final double DOUBLE_MULTIPLIER = 0x1.0p-52d; + /** Lowest byte mask. */ + private static final long LONG_LOWEST_BYTE_MASK = 0xffL; + /** Number of bytes in a {@code long} */ + private static final int LONG_SIZE = 8; + /** Lowest byte mask. */ + private static final int INT_LOWEST_BYTE_MASK = 0xff; + /** Number of bytes in a {@code int} */ + private static final int INT_SIZE = 4; + + /** + * Class contains only static methods. + */ + private NumberFactory() {} + + /** + * @param v Number. + * @return a boolean. + */ + public static boolean makeBoolean(int v) { + return (v >>> 31) != 0; + } + + /** + * @param v Number. + * @return a boolean. + */ + public static boolean makeBoolean(long v) { + return (v >>> 63) != 0; + } + + /** + * @param v Number. + * @return a {@code double} value in the interval {@code [0, 1]}. + */ + public static double makeDouble(long v) { + // http://xorshift.di.unimi.it + return Double.longBitsToDouble(DOUBLE_HIGH_BITS | v >>> 12) - 1d; + } + + /** + * @param v Number (high order bits). + * @param w Number (low order bits). + * @return a {@code double} value in the interval {@code [0, 1]}. + */ + public static double makeDouble(int v, + int w) { + final long high = ((long) (v >>> 6)) << 26; + final int low = w >>> 6; + return (high | low) * DOUBLE_MULTIPLIER; + } + + /** + * @param v Number. + * @return a {@code float} value in the interval {@code [0, 1]}. + */ + public static float makeFloat(int v) { + return (v >>> 9) * FLOAT_MULTIPLIER; + } + + /** + * @param v Number (high order bits). + * @param w Number (low order bits). + * @return a {@code long} value. + */ + public static long makeLong(int v, + int w) { + return (((long) v) << 32) | (w & 0xffffffffL); + } + + /** + * Creates an {@code int} from a {@code long}. + * + * @param v Number. + * @return an {@code int} value made from the "xor" of the + * {@link #extractHi(long) high order bits} and + * {@link #extractLo(long) low order bits} of {@code v}. + */ + public static int makeInt(long v) { + return extractHi(v) ^ extractLo(v); + } + + /** + * Creates an {@code int} from a {@code long}, using the high order bits. + * <p> + * The returned value is such that if + * <pre><code> + * vL = extractLo(v); + * vH = extractHi(v); + * </code></pre> + * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}. + * </p> + * + * @param v Number. + * @return an {@code int} value made from the most significant bits + * of {@code v}. + */ + public static int extractHi(long v) { + return (int) (v >>> 32); + } + + /** + * Creates an {@code int} from a {@code long}, using the low order bits. + * <p> + * The returned value is such that if + * <pre><code> + * vL = extractLo(v); + * vH = extractHi(v); + * </code></pre> + * then {@code v} is equal to {@link #makeLong(int,int) makeLong(vH, vL)}. + * </p> + * + * @param v Number. + * @return an {@code int} value made from the least significant bits + * of {@code v}. + */ + public static int extractLo(long v) { + return (int) v; + } + + /** + * Splits a {@code long} into 8 bytes. + * + * @param v Value. + * @return the bytes that compose the given value (least-significant + * byte first). + */ + public static byte[] makeByteArray(long v) { + final byte[] b = new byte[LONG_SIZE]; + + for (int i = 0; i < LONG_SIZE; i++) { + final int shift = i * 8; + b[i] = (byte) ((v >>> shift) & LONG_LOWEST_BYTE_MASK); + } + + return b; + } + + /** + * Creates a {@code long} from 8 bytes. + * + * @param input Input. + * @return the value that correspond to the given bytes assuming + * that the is ordered in increasing byte significance (i.e. the + * first byte in the array is the least-siginficant). + * @throws DimensionMismatchException if {@code input.length != 8}. + */ + public static long makeLong(byte[] input) { + if (input.length != LONG_SIZE) { + throw new DimensionMismatchException(input.length, LONG_SIZE); + } + + long v = 0; + for (int i = 0; i < LONG_SIZE; i++) { + final int shift = i * 8; + v |= (((long) input[i]) & LONG_LOWEST_BYTE_MASK) << shift; + } + + return v; + } + + /** + * Splits an array of {@code long} values into a sequence of bytes. + * This method calls {@link #makeByteArray(long)} for each element of + * the {@code input}. + * + * @param input Input. + * @return an array of bytes. + */ + public static byte[] makeByteArray(long[] input) { + final int size = input.length * LONG_SIZE; + final byte[] b = new byte[size]; + + for (int i = 0; i < input.length; i++) { + final byte[] current = makeByteArray(input[i]); + System.arraycopy(current, 0, b, i * LONG_SIZE, LONG_SIZE); + } + + return b; + } + + /** + * Creates an array of {@code long} values from a sequence of bytes. + * This method calls {@link #makeLong(byte[])} for each subsequence + * of 8 bytes. + * + * @param input Input. + * @return an array of {@code long}. + * @throws DimensionMismatchException if {@code input.length} is not + * a multiple of 8. + */ + public static long[] makeLongArray(byte[] input) { + final int size = input.length; + final int num = size / LONG_SIZE; + if (num * LONG_SIZE != size) { + throw new DimensionMismatchException(size, num * LONG_SIZE); + } + + final long[] output = new long[num]; + for (int i = 0; i < num; i++) { + final int from = i * LONG_SIZE; + final byte[] current = Arrays.copyOfRange(input, from, from + LONG_SIZE); + output[i] = makeLong(current); + } + + return output; + } + + /** + * Splits an {@code int} into 4 bytes. + * + * @param v Value. + * @return the bytes that compose the given value (least-significant + * byte first). + */ + public static byte[] makeByteArray(int v) { + final byte[] b = new byte[INT_SIZE]; + + for (int i = 0; i < INT_SIZE; i++) { + final int shift = i * 8; + b[i] = (byte) ((v >>> shift) & INT_LOWEST_BYTE_MASK); + } + + return b; + } + + /** + * Creates an {@code int} from 4 bytes. + * + * @param input Input. + * @return the value that correspond to the given bytes assuming + * that the is ordered in increasing byte significance (i.e. the + * first byte in the array is the least-siginficant). + * @throws DimensionMismatchException if {@code input.length != 4}. + */ + public static int makeInt(byte[] input) { + if (input.length != INT_SIZE) { + throw new DimensionMismatchException(input.length, INT_SIZE); + } + + int v = 0; + for (int i = 0; i < INT_SIZE; i++) { + final int shift = i * 8; + v |= (((int) input[i]) & INT_LOWEST_BYTE_MASK) << shift; + } + + return v; + } + + /** + * Splits an array of {@code int} values into a sequence of bytes. + * This method calls {@link #makeByteArray(int)} for each element of + * the {@code input}. + * + * @param input Input. + * @return an array of bytes. + */ + public static byte[] makeByteArray(int[] input) { + final int size = input.length * INT_SIZE; + final byte[] b = new byte[size]; + + for (int i = 0; i < input.length; i++) { + final byte[] current = makeByteArray(input[i]); + System.arraycopy(current, 0, b, i * INT_SIZE, INT_SIZE); + } + + return b; + } + + /** + * Creates an array of {@code int} values from a sequence of bytes. + * This method calls {@link #makeInt(byte[])} for each subsequence + * of 4 bytes. + * + * @param input Input. Length must be a multiple of 4. + * @return an array of {@code int}. + * @throws DimensionMismatchException if {@code input.length} is not + * a multiple of 4. + */ + public static int[] makeIntArray(byte[] input) { + final int size = input.length; + final int num = size / INT_SIZE; + if (num * INT_SIZE != size) { + throw new DimensionMismatchException(size, num * INT_SIZE); + } + + final int[] output = new int[num]; + for (int i = 0; i < num; i++) { + final int from = i * INT_SIZE; + final byte[] current = Arrays.copyOfRange(input, from, from + INT_SIZE); + output[i] = makeInt(current); + } + + return output; + } +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverter.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverter.java b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverter.java new file mode 100644 index 0000000..532277b --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverter.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + +/** + * Seed converter. + * + * @param <IN> Input seed type. + * @param <OUT> Output seed type. + * + * @since 4.0 + */ +public interface SeedConverter<IN, OUT> { + /** + * Converts seed from input type to output type. + * + * @param seed Original seed value. + * @return the converted seed value. + */ + OUT convert(IN seed); +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverterComposer.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverterComposer.java b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverterComposer.java new file mode 100644 index 0000000..c39c7d8 --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedConverterComposer.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + +/** + * Composes two {@link SeedConverter converters}. + * + * @param <IN> Input seed type. + * @param <TRANS> Transitional seed type. + * @param <OUT> Output seed type. + * + * @since 4.0 + */ +public class SeedConverterComposer<IN, TRANS, OUT> implements SeedConverter<IN, OUT> { + /** First conversion. */ + private SeedConverter<IN, TRANS> first; + /** Second conversion. */ + private SeedConverter<TRANS, OUT> second; + + /** + * @param first First conversion. + * @param second second conversion. + */ + public SeedConverterComposer(SeedConverter<IN, TRANS> first, + SeedConverter<TRANS, OUT> second) { + this.first = first; + this.second = second; + } + + /** {@inheritDoc} */ + @Override + public OUT convert(IN seed) { + final TRANS trans = first.convert(seed); + return second.convert(trans); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return getClass().getSimpleName() + " (" + second + " o " + first + ")"; + } +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/SeedFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/SeedFactory.java b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedFactory.java new file mode 100644 index 0000000..dc867f2 --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/SeedFactory.java @@ -0,0 +1,262 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math4.rng.internal.util; + +import org.apache.commons.math4.rng.internal.source32.RandomIntSource; +import org.apache.commons.math4.rng.internal.source32.Well44497b; +import org.apache.commons.math4.rng.internal.source64.RandomLongSource; +import org.apache.commons.math4.rng.internal.source64.SplitMix64; + +/** + * Utilities related to seeding. + * + * <p> + * This class provides methods to generate random seeds (single values + * or arrays of values, of {@code int} or {@code long} types) that can + * be passed to the {@link org.apache.commons.math4.rng.RandomSource + * methods that create a generator instance}. + * <br> + * Although the seed-generating methods defined in this class will likely + * return different values for all calls, there is no guarantee that the + * produced seed will result always in a "good" sequence of numbers (even + * if the generator initialized with that seed is good). + * <br> + * There is <i>no guarantee</i> that sequences will not overlap. + * </p> + * + * @since 4.0 + */ +public class SeedFactory { + /** Generator with a long period. */ + private static final RandomIntSource SEED_GENERATOR; + + static { + // Another RNG for initializing the "SEED_GENERATOR". + final long t = System.currentTimeMillis(); + final int h = System.identityHashCode(Runtime.getRuntime()); + final SplitMix64 rng = new SplitMix64(t ^ NumberFactory.makeLong(h, ~h)); + + final int blockCount = 1391; // Size of the state array of "Well44497b". + SEED_GENERATOR = new Well44497b(createIntArray(blockCount, rng)); + } + + /** + * Class contains only static methods. + */ + private SeedFactory() {} + + /** + * Creates a number for use as a seed. + * + * @return a random number. + */ + public static int createInt() { + return createInt(SEED_GENERATOR, System.identityHashCode(new Object())); + } + + /** + * Creates a number for use as a seed. + * + * @return a random number. + */ + public static long createLong() { + return createLong(SEED_GENERATOR, System.identityHashCode(new Object())); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @return an array of {@code n} random numbers. + */ + public static int[] createIntArray(int n) { + return createIntArray(n, SEED_GENERATOR, new Object()); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @return an array of {@code n} random numbers. + */ + public static long[] createLongArray(int n) { + return createLongArray(n, SEED_GENERATOR, new Object()); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @return an array of {@code n} random numbers drawn from the + * {@code source}. + */ + static long[] createLongArray(int n, + RandomIntSource source) { + return createLongArray(n, source, null); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @return an array of {@code n} random numbers drawn from the + * {@code source}. + */ + static int[] createIntArray(int n, + RandomLongSource source) { + return createIntArray(n, source, null); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @return an array of {@code n} random numbers drawn from the + * {@code source}. + */ + static int[] createIntArray(int n, + RandomIntSource source) { + return createIntArray(n, source, null); + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @param h Arbitrary object whose {@link System#identityHashCode(Object) + * hash code} will be combined with the next number drawn from + * the {@code source}. + * @return an array of {@code n} random numbers. + */ + private static long[] createLongArray(int n, + RandomIntSource source, + Object h) { + final long[] array = new long[n]; + + final int hash = System.identityHashCode(h); + for (int i = 0; i < n; i++) { + array[i] = createLong(source, hash); + } + + return array; + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @param h Arbitrary object whose {@link System#identityHashCode(Object) + * hash code} will be combined with the next number drawn from + * the {@code source}. + * @return an array of {@code n} random numbers. + */ + private static int[] createIntArray(int n, + RandomLongSource source, + Object h) { + final int[] array = new int[n]; + + final int hash = System.identityHashCode(h); + for (int i = 0; i < n; i += 2) { + final long v = createLong(source, hash); + + array[i] = NumberFactory.extractHi(v); + + if (i + 1 < n) { + array[i + 1] = NumberFactory.extractLo(v); + } + } + + return array; + } + + /** + * Creates an array of numbers for use as a seed. + * + * @param n Size of the array to create. + * @param source Source of randomness. + * @param h Arbitrary object whose {@link System#identityHashCode(Object) + * hash code} will be combined with the next number drawn from + * the {@code source}. + * @return an array of {@code n} random numbers. + */ + private static int[] createIntArray(int n, + RandomIntSource source, + Object h) { + final int[] array = new int[n]; + + final int hash = System.identityHashCode(h); + for (int i = 0; i < n; i++) { + array[i] = createInt(source, hash); + } + + return array; + } + + /** + * Creates a random number by performing an "xor" between the + * next value in the sequence of the {@code source} and the + * given {@code number}. + * + * @param source Source of randomness. + * @param number Arbitrary number. + * @return a random number. + */ + private static long createLong(RandomLongSource source, + int number) { + synchronized (source) { + return source.next() ^ NumberFactory.makeLong(number, number); + } + } + + /** + * Creates a random number by performing an "xor" between the + * the next value in the sequence of the {@code source} and the + * given {@code number}. + * + * @param source Source of randomness. + * @param number Arbitrary number. + * @return a random number. + */ + private static long createLong(RandomIntSource source, + int number) { + synchronized (source) { + return NumberFactory.makeLong(source.next() ^ number, + source.next() ^ number); + } + } + + /** + * Creates a random number by performing an "xor" between the + * next value in the sequence of the {@code source} and the + * given {@code number}. + * + * @param source Source of randomness. + * @param number Arbitrary number. + * @return a random number. + */ + private static int createInt(RandomIntSource source, + int number) { + synchronized (source) { + return source.next() ^ number; + } + } +} http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/internal/util/package-info.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/internal/util/package-info.java b/src/main/java/org/apache/commons/math4/rng/internal/util/package-info.java new file mode 100644 index 0000000..9ce5213 --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/internal/util/package-info.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Utilities for seed conversion. + */ + +package org.apache.commons.math4.rng.internal.util; http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/main/java/org/apache/commons/math4/rng/package-info.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/math4/rng/package-info.java b/src/main/java/org/apache/commons/math4/rng/package-info.java new file mode 100644 index 0000000..19c5755 --- /dev/null +++ b/src/main/java/org/apache/commons/math4/rng/package-info.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * <h3>Randomness Providers</h3> + * + * <p> + * This package contains the public API for generating sequences of + * pseudo-random numbers that are <i>uniformly distributed</i> in a + * specified range. + * <br> + * All implemented generators can be instantiated through + * {@link org.apache.commons.math4.rng.RandomSource factory methods}. + * The low-level classes, that define how the randomness is produced, + * are implemented in package {@link org.apache.commons.math4.rng.internal} + * and its sub-packages, but should not be used directly. + * <br> + * The generators are <i>not</i> thread-safe: Parallel applications must + * use different generator instances in different threads. + * </p> + * + * <p> + * In the case of pseudo-random generators, the source of randomness is + * usually a set of numbers whose bits representation are scrambled in such + * a way as to produce a random-looking sequence. + * <br> + * The main property of the sequence is that the numbers must be uniformly + * distributed within their allowed range. + * <br> + * Classes in this package do not provide any further processing of the + * number generation such as to match other types of distribution. + * </p> + * + * <p> + * Which source of randomness to choose may depend on which properties + * are more important. + * Considerations can include speed of generation, memory usage, period + * size, equidistribution, correlation, etc. + * <br> + * For some of the generators, interesting properties (of the reference + * implementations) are proven in scientific papers. + * Some generators can also suffer from potential weaknesses. + * </p> + * + * <p> + * For simple sampling, any of the generators implemented in this library + * may be sufficient. + * <br> + * For Monte-Carlo simulations that require generating high-dimensional + * vectors), equidistribution and non-correlation are crucial. + * The <i>Mersenne Twister</i> and <i>Well</i> generators have + * equidistribution properties proven according to their bits pool size + * which is directly related to their period (all of them have maximal + * period, i.e. a generator with size {@code n} pool has a period + * <code>2<sup>n</sup>-1</code>). + * They also have equidistribution properties for 32 bits blocks up to + * {@code s/32} dimension where {@code s} is their pool size. + * <br> + * For example, {@code Well19937c} is equidistributed up to dimension 623 + * (i.e. 19937 divided by 32). + * It means that a Monte-Carlo simulation generating vectors of {@code n} + * (32-bits integer) variables at each iteration has some guarantee on the + * properties of its components as long as {@code n < 623}. + * Note that if the variables are of type {@code double}, the limit is + * divided by two (since 64 bits are needed to create a {@code double}). + * <br> + * Reference to the relevant publications are listed in the specific + * documentation of each class. + * </p> + * + * <p> + * Memory usage can vary a lot between providers. + * The state of {@code MersenneTwister} is composed of 624 integers, + * using about 2.5 kB. + * The <i>Well</i> generators use 6 integer arrays, the length of each + * being equal to the pool size; thus, for example, {@code Well44497b} + * uses about 33 kB. + * </p> + */ + +package org.apache.commons.math4.rng; http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/site/apt/userguide/rng.apt ---------------------------------------------------------------------- diff --git a/src/site/apt/userguide/rng.apt b/src/site/apt/userguide/rng.apt new file mode 100644 index 0000000..a4931b8 --- /dev/null +++ b/src/site/apt/userguide/rng.apt @@ -0,0 +1,228 @@ +~~ +~~ Licensed to the Apache Software Foundation (ASF) under one or more +~~ contributor license agreements. See the NOTICE file distributed with +~~ this work for additional information regarding copyright ownership. +~~ The ASF licenses this file to You under the Apache License, Version 2.0 +~~ (the "License"); you may not use this file except in compliance with +~~ the License. You may obtain a copy of the License at +~~ +~~ http://www.apache.org/licenses/LICENSE-2.0 +~~ +~~ Unless required by applicable law or agreed to in writing, software +~~ distributed under the License is distributed on an "AS IS" BASIS, +~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~~ See the License for the specific language governing permissions and +~~ limitations under the License. +~~ + + ----------------------------------------------- + The Commons Math User Guide - Random Number Generators + ----------------------------------------------- + +20 Random Number Generators + + +* 20.1 Overview + + The <<<rng>>> package contains the random number generation functionality. + Please refer to the {{{../apidocs/org/apache/commons/math4/rng/package-summary.html}Javadoc}} of the package for details. + + + +* 20.2 Performance + + This section reports benchmarks of the RNG implementations. + All runs were performed on a platform with the following characteristics: + + * CPU: Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz + + * Java runtime: 1.7.0_95-b00 + + * JVM: OpenJDK 64-Bit Server VM 24.95-b01 + + [] + + The following tables indicates the performance for generating + + * a sequence of 32-bits integers (a.k.a. Java type <<<int>>>) + + * a sequence of 64-bits integers (a.k.a. Java type <<<long>>>) + + * a sequence of 64-bits floating point numbers (a.k.a. Java type <<<double>>>) + + [] + + The first column is the RNG identifier (see {{{../apidocs/org/apache/commons/math4/rng/RandomSource.html}RandomSource}}). + + Two independent benchmarking tools were used: + + * Commons Math <<<PerfTestUtils>>> + + * {{{http://openjdk.java.net/projects/code-tools/jmh/}JMH}} + + [] + + The results of those tools are reported in second and third columns, respectively, where + the value is the ratio of the performance of the implementation with respect to the + corresponding performance of the JDK's <<<java.util.Random>>> class. + In these tables, <lower> is <better>. + + + +** Generating <<<int>>> values + + +*---------------------------------*------------------------+--------------+ +|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) | +*---------------------------------*------------------------+--------------+ +| JDK | 1.21 | 1.000 | +*---------------------------------*------------------------+--------------+ +| MT | 1.19 | 0.639 | +*---------------------------------*------------------------+--------------+ +| WELL_512_A | 1.33 | 0.740 | +*---------------------------------*------------------------+--------------+ +| WELL_1024_A | 1.38 | 0.795 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_A | 1.47 | 1.039 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_C | 1.54 | 1.102 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_A | 1.53 | 1.187 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_B | 1.59 | 1.114 | +*---------------------------------*------------------------+--------------+ +| ISAAC | 1.30 | 0.610 | +*---------------------------------*------------------------+--------------+ +| MT_64 | 1.31 | 0.734 | +*---------------------------------*------------------------+--------------+ +| SPLIT_MIX_64 | 1.00 | 0.361 | +*---------------------------------*------------------------+--------------+ +| XOR_SHIFT_1024_S | 1.09 | 0.450 | +*---------------------------------*------------------------+--------------+ +| TWO_CMRES | 1.14 | 0.464 | +*---------------------------------*------------------------+--------------+ + + + +** Generating <<<long>>> values + + +*---------------------------------*------------------------+--------------+ +|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) | +*---------------------------------*------------------------+--------------+ +| JDK | 1.40 | 1.002 | +*---------------------------------*------------------------+--------------+ +| MT | 0.85 | 0.569 | +*---------------------------------*------------------------+--------------+ +| WELL_512_A | 1.05 | 0.798 | +*---------------------------------*------------------------+--------------+ +| WELL_1024_A | 1.08 | 0.873 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_A | 1.21 | 0.968 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_C | 1.27 | 1.020 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_A | 1.26 | 1.103 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_B | 1.31 | 1.043 | +*---------------------------------*------------------------+--------------+ +| ISAAC | 0.96 | 0.515 | +*---------------------------------*------------------------+--------------+ +| MT_64 | 0.67 | 0.343 | +*---------------------------------*------------------------+--------------+ +| SPLIT_MIX_64 | 0.55 | 0.175 | +*---------------------------------*------------------------+--------------+ +| XOR_SHIFT_1024_S | 0.59 | 0.207 | +*---------------------------------*------------------------+--------------+ +| TWO_CMRES | 0.61 | 0.223 | +*---------------------------------*------------------------+--------------+ + + + +** Generating <<<double>>> values + + +*---------------------------------*------------------------+--------------+ +|| RNG identifier || Ratio (PerfTestUtils) || Ratio (JMH) | +*---------------------------------*------------------------+--------------+ +| JDK | 1.15 | 1.001 | +*---------------------------------*------------------------+--------------+ +| MT | 0.86 | 0.614 | +*---------------------------------*------------------------+--------------+ +| WELL_512_A | 1.08 | 0.839 | +*---------------------------------*------------------------+--------------+ +| WELL_1024_A | 1.11 | 0.899 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_A | 1.23 | 0.984 | +*---------------------------------*------------------------+--------------+ +| WELL_19937_C | 1.29 | 1.069 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_A | 1.28 | 1.125 | +*---------------------------------*------------------------+--------------+ +| WELL_44497_B | 1.33 | 1.093 | +*---------------------------------*------------------------+--------------+ +| ISAAC | 0.98 | 0.583 | +*---------------------------------*------------------------+--------------+ +| MT_64 | 0.66 | 0.391 | +*---------------------------------*------------------------+--------------+ +| SPLIT_MIX_64 | 0.57 | 0.226 | +*---------------------------------*------------------------+--------------+ +| XOR_SHIFT_1024_S | 0.59 | 0.262 | +*---------------------------------*------------------------+--------------+ +| TWO_CMRES | 0.60 | 0.284 | +*---------------------------------*------------------------+--------------+ + + +* 20.3 Quality + + This section reports results of performing "stress tests" that aim at detecting failures + of an implementation to produce sequences of numbers that follow a uniform distribution. + + Two different test suites were used: + + * {{{http://www.phy.duke.edu/~rgb/General/dieharder.php}Dieharder}} + + * {{{http://simul.iro.umontreal.ca/testu01/tu01.html}TestU01}} + + [] + + The first column is the RNG identifier (see {{{../apidocs/org/apache/commons/math4/rng/RandomSource.html}RandomSource}}). + The second and third columns contain the number of tests which <Dieharder> and <TestU01> + respectively reported as below the accepted threshold for considering the sequence as + uniformly random; hence, in this table, <lower> is <better>. + + For each the two test suites, two runs were performed (using random seeds): Click on one + of the numbers of the comma-separated list in order to see the text report of the + corresponding run. + Note: For <Dieharder>, a failure on the "Diehard Sums Test" can be {{{http://www.phy.duke.edu/~rgb/General/dieharder.php}ignored}}. + + +*---------------------------------*----------------*---------------------* +|| RNG identifier || Dieharder || TestU01 (BigCrush) | +*----------------*----------------*----------------*---------------------* +| JDK | {{{../txt/userguide/rng/stress/dh/run_1/dh_1}13}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_1}11}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_1}77}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_1}74}} | +*---------------------------------*----------------*----------------* +| MT | {{{../txt/userguide/rng/stress/dh/run_1/dh_2}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_2}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_2}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_2}2}} | +*---------------------------------*----------------*----------------* +| WELL_512_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_3}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_3}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_3}6}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_3}7}} | +*---------------------------------*----------------*----------------* +| WELL_1024_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_4}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_4}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_4}5}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_4}4}} | +*---------------------------------*----------------*----------------* +| WELL_19937_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_5}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_5}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_5}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_5}3}} | +*---------------------------------*----------------*----------------* +| WELL_19937_C | {{{../txt/userguide/rng/stress/dh/run_1/dh_6}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_6}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_6}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_6}2}} | +*---------------------------------*----------------*----------------* +| WELL_44497_A | {{{../txt/userguide/rng/stress/dh/run_1/dh_7}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_7}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_7}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_7}2}} | +*---------------------------------*----------------*----------------* +| WELL_44497_B | {{{../txt/userguide/rng/stress/dh/run_1/dh_8}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_8}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_8}3}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_8}2}} | +*---------------------------------*----------------*----------------* +| ISAAC | {{{../txt/userguide/rng/stress/dh/run_1/dh_9}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_9}1}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_9}1}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_9}0}} | +*---------------------------------*----------------*----------------* +| MT_64 | {{{../txt/userguide/rng/stress/dh/run_1/dh_10}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_10}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_10}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_10}2}} | +*---------------------------------*----------------*----------------* +| SPLIT_MIX_64 | {{{../txt/userguide/rng/stress/dh/run_1/dh_11}1}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_11}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_11}0}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_11}0}} | +*---------------------------------*----------------*----------------* +| XOR_SHIFT_1024_S | {{{../txt/userguide/rng/stress/dh/run_1/dh_12}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_12}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_12}2}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_12}0}} | +*---------------------------------*----------------*----------------* +| TWO_CMRES | {{{../txt/userguide/rng/stress/dh/run_1/dh_13}0}}, {{{../txt/userguide/rng/stress/dh/run_2/dh_13}0}} | {{{../txt/userguide/rng/stress/tu/run_1/tu_13}1}}, {{{../txt/userguide/rng/stress/tu/run_2/tu_13}0}} | +*---------------------------------*----------------*----------------* http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_1 ---------------------------------------------------------------------- diff --git a/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_1 b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_1 new file mode 100644 index 0000000..224d2a0 --- /dev/null +++ b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_1 @@ -0,0 +1,146 @@ +# +# RNG: org.apache.commons.math4.rng.internal.source32.JDKRandom +# +# Java: 1.8.0_66 +# Runtime: 1.8.0_66-b17 +# JVM: Java HotSpot(TM) 64-Bit Server VM 25.66-b17 +# OS: Linux 3.16.0-4-amd64 amd64 +# +# Analyzer: /usr/bin/dieharder -a -g 200 -Y 1 -k 2 +# +#=============================================================================# +# dieharder version 3.31.1 Copyright 2003 Robert G. Brown # +#=============================================================================# + rng_name |rands/second| Seed | +stdin_input_raw| 8.46e+06 |3234096741| +#=============================================================================# + test_name |ntup| tsamples |psamples| p-value |Assessment +#=============================================================================# + diehard_birthdays| 0| 100| 100|0.03946185| PASSED + diehard_operm5| 0| 1000000| 100|0.01629539| PASSED + diehard_rank_32x32| 0| 40000| 100|0.98579998| PASSED + diehard_rank_6x8| 0| 100000| 100|0.53483219| PASSED + diehard_bitstream| 0| 2097152| 100|0.99560702| WEAK + diehard_bitstream| 0| 2097152| 200|0.47019123| PASSED + diehard_opso| 0| 2097152| 100|0.58743463| PASSED + diehard_oqso| 0| 2097152| 100|0.00000000| FAILED + diehard_dna| 0| 2097152| 100|0.00000000| FAILED +diehard_count_1s_str| 0| 256000| 100|0.90699558| PASSED +diehard_count_1s_byt| 0| 256000| 100|0.97545849| PASSED + diehard_parking_lot| 0| 12000| 100|0.01296474| PASSED + diehard_2dsphere| 2| 8000| 100|0.51391418| PASSED + diehard_3dsphere| 3| 4000| 100|0.18584250| PASSED + diehard_squeeze| 0| 100000| 100|0.00726652| PASSED + diehard_sums| 0| 100| 100|0.40869228| PASSED + diehard_runs| 0| 100000| 100|0.05169565| PASSED + diehard_runs| 0| 100000| 100|0.98866390| PASSED + diehard_craps| 0| 200000| 100|0.35494552| PASSED + diehard_craps| 0| 200000| 100|0.47365191| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.14780252| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.29338446| PASSED + sts_monobit| 1| 100000| 100|0.97888201| PASSED + sts_runs| 2| 100000| 100|0.74655596| PASSED + sts_serial| 1| 100000| 100|0.41897552| PASSED + sts_serial| 2| 100000| 100|0.38034056| PASSED + sts_serial| 3| 100000| 100|0.99170185| PASSED + sts_serial| 3| 100000| 100|0.76457270| PASSED + sts_serial| 4| 100000| 100|0.80172413| PASSED + sts_serial| 4| 100000| 100|0.52177712| PASSED + sts_serial| 5| 100000| 100|0.99297019| PASSED + sts_serial| 5| 100000| 100|0.59183271| PASSED + sts_serial| 6| 100000| 100|0.94001454| PASSED + sts_serial| 6| 100000| 100|0.39218216| PASSED + sts_serial| 7| 100000| 100|0.69888838| PASSED + sts_serial| 7| 100000| 100|0.16541368| PASSED + sts_serial| 8| 100000| 100|0.47131229| PASSED + sts_serial| 8| 100000| 100|0.09817778| PASSED + sts_serial| 9| 100000| 100|0.42261781| PASSED + sts_serial| 9| 100000| 100|0.05344107| PASSED + sts_serial| 10| 100000| 100|0.77804588| PASSED + sts_serial| 10| 100000| 100|0.57799732| PASSED + sts_serial| 11| 100000| 100|0.01016312| PASSED + sts_serial| 11| 100000| 100|0.06073112| PASSED + sts_serial| 12| 100000| 100|0.65917138| PASSED + sts_serial| 12| 100000| 100|0.63230695| PASSED + sts_serial| 13| 100000| 100|0.84190399| PASSED + sts_serial| 13| 100000| 100|0.85277783| PASSED + sts_serial| 14| 100000| 100|0.49213152| PASSED + sts_serial| 14| 100000| 100|0.30112917| PASSED + sts_serial| 15| 100000| 100|0.14544079| PASSED + sts_serial| 15| 100000| 100|0.94737293| PASSED + sts_serial| 16| 100000| 100|0.39262889| PASSED + sts_serial| 16| 100000| 100|0.84185055| PASSED + rgb_bitdist| 1| 100000| 100|0.54063417| PASSED + rgb_bitdist| 2| 100000| 100|0.09286365| PASSED + rgb_bitdist| 3| 100000| 100|0.27436056| PASSED + rgb_bitdist| 4| 100000| 100|0.10595606| PASSED + rgb_bitdist| 5| 100000| 100|0.72828807| PASSED + rgb_bitdist| 6| 100000| 100|0.78439941| PASSED + rgb_bitdist| 7| 100000| 100|0.54939794| PASSED + rgb_bitdist| 8| 100000| 100|0.49285600| PASSED + rgb_bitdist| 9| 100000| 100|0.55836635| PASSED + rgb_bitdist| 10| 100000| 100|0.09735886| PASSED + rgb_bitdist| 11| 100000| 100|0.99987371| WEAK + rgb_bitdist| 11| 100000| 200|0.72189984| PASSED + rgb_bitdist| 12| 100000| 100|0.16961094| PASSED +rgb_minimum_distance| 2| 10000| 1000|0.20393701| PASSED +rgb_minimum_distance| 3| 10000| 1000|0.00000002| FAILED +rgb_minimum_distance| 4| 10000| 1000|0.00000000| FAILED +rgb_minimum_distance| 5| 10000| 1000|0.00000000| FAILED + rgb_permutations| 2| 100000| 100|0.57021718| PASSED + rgb_permutations| 3| 100000| 100|0.62537216| PASSED + rgb_permutations| 4| 100000| 100|0.34391663| PASSED + rgb_permutations| 5| 100000| 100|0.51106315| PASSED + rgb_lagged_sum| 0| 1000000| 100|0.75921017| PASSED + rgb_lagged_sum| 1| 1000000| 100|0.11901881| PASSED + rgb_lagged_sum| 2| 1000000| 100|0.98766090| PASSED + rgb_lagged_sum| 3| 1000000| 100|0.59129144| PASSED + rgb_lagged_sum| 4| 1000000| 100|0.42126930| PASSED + rgb_lagged_sum| 5| 1000000| 100|0.28570675| PASSED + rgb_lagged_sum| 6| 1000000| 100|0.61879754| PASSED + rgb_lagged_sum| 7| 1000000| 100|0.44777033| PASSED + rgb_lagged_sum| 8| 1000000| 100|0.95714236| PASSED + rgb_lagged_sum| 9| 1000000| 100|0.55158775| PASSED + rgb_lagged_sum| 10| 1000000| 100|0.99968320| WEAK + rgb_lagged_sum| 10| 1000000| 200|0.94120047| PASSED + rgb_lagged_sum| 11| 1000000| 100|0.00001553| WEAK + rgb_lagged_sum| 11| 1000000| 200|0.00000000| FAILED + rgb_lagged_sum| 12| 1000000| 100|0.88935254| PASSED + rgb_lagged_sum| 13| 1000000| 100|0.76358163| PASSED + rgb_lagged_sum| 14| 1000000| 100|0.93169219| PASSED + rgb_lagged_sum| 15| 1000000| 100|0.00000000| FAILED + rgb_lagged_sum| 16| 1000000| 100|0.97118631| PASSED + rgb_lagged_sum| 17| 1000000| 100|0.94598742| PASSED + rgb_lagged_sum| 18| 1000000| 100|0.59454816| PASSED + rgb_lagged_sum| 19| 1000000| 100|0.00027545| WEAK + rgb_lagged_sum| 19| 1000000| 200|0.00000001| FAILED + rgb_lagged_sum| 20| 1000000| 100|0.87996908| PASSED + rgb_lagged_sum| 21| 1000000| 100|0.76558265| PASSED + rgb_lagged_sum| 22| 1000000| 100|0.35273627| PASSED + rgb_lagged_sum| 23| 1000000| 100|0.00007767| WEAK + rgb_lagged_sum| 23| 1000000| 200|0.00000000| FAILED + rgb_lagged_sum| 24| 1000000| 100|0.48030158| PASSED + rgb_lagged_sum| 25| 1000000| 100|0.98040339| PASSED + rgb_lagged_sum| 26| 1000000| 100|0.58094512| PASSED + rgb_lagged_sum| 27| 1000000| 100|0.26354148| PASSED + rgb_lagged_sum| 28| 1000000| 100|0.02516105| PASSED + rgb_lagged_sum| 29| 1000000| 100|0.19290606| PASSED + rgb_lagged_sum| 30| 1000000| 100|0.98500384| PASSED + rgb_lagged_sum| 31| 1000000| 100|0.00000000| FAILED + rgb_lagged_sum| 32| 1000000| 100|0.73025626| PASSED + rgb_kstest_test| 0| 10000| 1000|0.02497988| PASSED + dab_bytedistrib| 0| 51200000| 1|1.00000000| FAILED + dab_dct| 256| 50000| 1|0.92579052| PASSED +Preparing to run test 207. ntuple = 0 + dab_filltree| 32| 15000000| 1|0.00000240| WEAK + dab_filltree| 32| 15000000| 1|0.00309996| WEAK + dab_filltree| 32| 15000000| 101|0.00000000| FAILED + dab_filltree| 32| 15000000| 101|0.00000000| FAILED +Preparing to run test 208. ntuple = 0 + dab_filltree2| 0| 5000000| 1|0.24726392| PASSED + dab_filltree2| 1| 5000000| 1|0.74594891| PASSED +Preparing to run test 209. ntuple = 0 + dab_monobit2| 12| 65000000| 1|0.66141319| PASSED +# +# Test duration: 165.6195733010167 minutes +# http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_10 ---------------------------------------------------------------------- diff --git a/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_10 b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_10 new file mode 100644 index 0000000..bf7b31d --- /dev/null +++ b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_10 @@ -0,0 +1,139 @@ +# +# RNG: org.apache.commons.math4.rng.internal.source64.MersenneTwister64 +# +# Java: 1.8.0_66 +# Runtime: 1.8.0_66-b17 +# JVM: Java HotSpot(TM) 64-Bit Server VM 25.66-b17 +# OS: Linux 3.16.0-4-amd64 amd64 +# +# Analyzer: /usr/bin/dieharder -a -g 200 -Y 1 -k 2 +# +#=============================================================================# +# dieharder version 3.31.1 Copyright 2003 Robert G. Brown # +#=============================================================================# + rng_name |rands/second| Seed | +stdin_input_raw| 8.35e+06 |4060973066| +#=============================================================================# + test_name |ntup| tsamples |psamples| p-value |Assessment +#=============================================================================# + diehard_birthdays| 0| 100| 100|0.38038146| PASSED + diehard_operm5| 0| 1000000| 100|0.82073994| PASSED + diehard_rank_32x32| 0| 40000| 100|0.99419941| PASSED + diehard_rank_6x8| 0| 100000| 100|0.84421559| PASSED + diehard_bitstream| 0| 2097152| 100|0.68114221| PASSED + diehard_opso| 0| 2097152| 100|0.49571971| PASSED + diehard_oqso| 0| 2097152| 100|0.50489838| PASSED + diehard_dna| 0| 2097152| 100|0.56038693| PASSED +diehard_count_1s_str| 0| 256000| 100|0.52187833| PASSED +diehard_count_1s_byt| 0| 256000| 100|0.82794918| PASSED + diehard_parking_lot| 0| 12000| 100|0.94334354| PASSED + diehard_2dsphere| 2| 8000| 100|0.41934767| PASSED + diehard_3dsphere| 3| 4000| 100|0.38986875| PASSED + diehard_squeeze| 0| 100000| 100|0.30645416| PASSED + diehard_sums| 0| 100| 100|0.95555200| PASSED + diehard_runs| 0| 100000| 100|0.45678041| PASSED + diehard_runs| 0| 100000| 100|0.77628546| PASSED + diehard_craps| 0| 200000| 100|0.66628776| PASSED + diehard_craps| 0| 200000| 100|0.74815016| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.42574679| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.95301550| PASSED + sts_monobit| 1| 100000| 100|0.01768472| PASSED + sts_runs| 2| 100000| 100|0.66990502| PASSED + sts_serial| 1| 100000| 100|0.56397489| PASSED + sts_serial| 2| 100000| 100|0.14554819| PASSED + sts_serial| 3| 100000| 100|0.10532469| PASSED + sts_serial| 3| 100000| 100|0.50086684| PASSED + sts_serial| 4| 100000| 100|0.87214766| PASSED + sts_serial| 4| 100000| 100|0.96260182| PASSED + sts_serial| 5| 100000| 100|0.46155357| PASSED + sts_serial| 5| 100000| 100|0.93540615| PASSED + sts_serial| 6| 100000| 100|0.06399709| PASSED + sts_serial| 6| 100000| 100|0.37475484| PASSED + sts_serial| 7| 100000| 100|0.19960274| PASSED + sts_serial| 7| 100000| 100|0.71409873| PASSED + sts_serial| 8| 100000| 100|0.58265537| PASSED + sts_serial| 8| 100000| 100|0.30875682| PASSED + sts_serial| 9| 100000| 100|0.89120538| PASSED + sts_serial| 9| 100000| 100|0.08055589| PASSED + sts_serial| 10| 100000| 100|0.94326678| PASSED + sts_serial| 10| 100000| 100|0.63560702| PASSED + sts_serial| 11| 100000| 100|0.63552036| PASSED + sts_serial| 11| 100000| 100|0.41447321| PASSED + sts_serial| 12| 100000| 100|0.11137836| PASSED + sts_serial| 12| 100000| 100|0.31247769| PASSED + sts_serial| 13| 100000| 100|0.11571281| PASSED + sts_serial| 13| 100000| 100|0.34165091| PASSED + sts_serial| 14| 100000| 100|0.45691599| PASSED + sts_serial| 14| 100000| 100|0.86847228| PASSED + sts_serial| 15| 100000| 100|0.20344802| PASSED + sts_serial| 15| 100000| 100|0.01403264| PASSED + sts_serial| 16| 100000| 100|0.49704173| PASSED + sts_serial| 16| 100000| 100|0.99251040| PASSED + rgb_bitdist| 1| 100000| 100|0.82107588| PASSED + rgb_bitdist| 2| 100000| 100|0.26857984| PASSED + rgb_bitdist| 3| 100000| 100|0.74121909| PASSED + rgb_bitdist| 4| 100000| 100|0.85664588| PASSED + rgb_bitdist| 5| 100000| 100|0.14846957| PASSED + rgb_bitdist| 6| 100000| 100|0.58492538| PASSED + rgb_bitdist| 7| 100000| 100|0.50773594| PASSED + rgb_bitdist| 8| 100000| 100|0.51477335| PASSED + rgb_bitdist| 9| 100000| 100|0.58560247| PASSED + rgb_bitdist| 10| 100000| 100|0.73157176| PASSED + rgb_bitdist| 11| 100000| 100|0.35133278| PASSED + rgb_bitdist| 12| 100000| 100|0.69691200| PASSED +rgb_minimum_distance| 2| 10000| 1000|0.11088599| PASSED +rgb_minimum_distance| 3| 10000| 1000|0.56158689| PASSED +rgb_minimum_distance| 4| 10000| 1000|0.85110247| PASSED +rgb_minimum_distance| 5| 10000| 1000|0.85208203| PASSED + rgb_permutations| 2| 100000| 100|0.30212792| PASSED + rgb_permutations| 3| 100000| 100|0.37729899| PASSED + rgb_permutations| 4| 100000| 100|0.32979222| PASSED + rgb_permutations| 5| 100000| 100|0.68814175| PASSED + rgb_lagged_sum| 0| 1000000| 100|0.57882968| PASSED + rgb_lagged_sum| 1| 1000000| 100|0.93734672| PASSED + rgb_lagged_sum| 2| 1000000| 100|0.64486630| PASSED + rgb_lagged_sum| 3| 1000000| 100|0.94899438| PASSED + rgb_lagged_sum| 4| 1000000| 100|0.12065130| PASSED + rgb_lagged_sum| 5| 1000000| 100|0.98819337| PASSED + rgb_lagged_sum| 6| 1000000| 100|0.05992105| PASSED + rgb_lagged_sum| 7| 1000000| 100|0.07167199| PASSED + rgb_lagged_sum| 8| 1000000| 100|0.56228730| PASSED + rgb_lagged_sum| 9| 1000000| 100|0.10534144| PASSED + rgb_lagged_sum| 10| 1000000| 100|0.53198515| PASSED + rgb_lagged_sum| 11| 1000000| 100|0.97513880| PASSED + rgb_lagged_sum| 12| 1000000| 100|0.84345586| PASSED + rgb_lagged_sum| 13| 1000000| 100|0.68663096| PASSED + rgb_lagged_sum| 14| 1000000| 100|0.90102702| PASSED + rgb_lagged_sum| 15| 1000000| 100|0.33847765| PASSED + rgb_lagged_sum| 16| 1000000| 100|0.60279321| PASSED + rgb_lagged_sum| 17| 1000000| 100|0.58322395| PASSED + rgb_lagged_sum| 18| 1000000| 100|0.42415615| PASSED + rgb_lagged_sum| 19| 1000000| 100|0.36335552| PASSED + rgb_lagged_sum| 20| 1000000| 100|0.81338367| PASSED + rgb_lagged_sum| 21| 1000000| 100|0.75672514| PASSED + rgb_lagged_sum| 22| 1000000| 100|0.72069324| PASSED + rgb_lagged_sum| 23| 1000000| 100|0.31844638| PASSED + rgb_lagged_sum| 24| 1000000| 100|0.94061253| PASSED + rgb_lagged_sum| 25| 1000000| 100|0.83342998| PASSED + rgb_lagged_sum| 26| 1000000| 100|0.31439533| PASSED + rgb_lagged_sum| 27| 1000000| 100|0.97325800| PASSED + rgb_lagged_sum| 28| 1000000| 100|0.84734559| PASSED + rgb_lagged_sum| 29| 1000000| 100|0.93209485| PASSED + rgb_lagged_sum| 30| 1000000| 100|0.51632833| PASSED + rgb_lagged_sum| 31| 1000000| 100|0.99249230| PASSED + rgb_lagged_sum| 32| 1000000| 100|0.11288279| PASSED + rgb_kstest_test| 0| 10000| 1000|0.62750032| PASSED + dab_bytedistrib| 0| 51200000| 1|0.64126517| PASSED + dab_dct| 256| 50000| 1|0.73583907| PASSED +Preparing to run test 207. ntuple = 0 + dab_filltree| 32| 15000000| 1|0.91066506| PASSED + dab_filltree| 32| 15000000| 1|0.72068986| PASSED +Preparing to run test 208. ntuple = 0 + dab_filltree2| 0| 5000000| 1|0.43062103| PASSED + dab_filltree2| 1| 5000000| 1|0.68290109| PASSED +Preparing to run test 209. ntuple = 0 + dab_monobit2| 12| 65000000| 1|0.99593445| WEAK + dab_monobit2| 12| 65000000| 101|0.01209486| PASSED +# +# Test duration: 127.73469639051667 minutes +# http://git-wip-us.apache.org/repos/asf/commons-math/blob/6ddf4769/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_11 ---------------------------------------------------------------------- diff --git a/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_11 b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_11 new file mode 100644 index 0000000..628a507 --- /dev/null +++ b/src/site/resources/txt/userguide/rng/stress/dh/run_1/dh_11 @@ -0,0 +1,148 @@ +# +# RNG: org.apache.commons.math4.rng.internal.source64.SplitMix64 +# +# Java: 1.8.0_66 +# Runtime: 1.8.0_66-b17 +# JVM: Java HotSpot(TM) 64-Bit Server VM 25.66-b17 +# OS: Linux 3.16.0-4-amd64 amd64 +# +# Analyzer: /usr/bin/dieharder -a -g 200 -Y 1 -k 2 +# +#=============================================================================# +# dieharder version 3.31.1 Copyright 2003 Robert G. Brown # +#=============================================================================# + rng_name |rands/second| Seed | +stdin_input_raw| 6.56e+06 |3876872701| +#=============================================================================# + test_name |ntup| tsamples |psamples| p-value |Assessment +#=============================================================================# + diehard_birthdays| 0| 100| 100|0.89394608| PASSED + diehard_operm5| 0| 1000000| 100|0.44622126| PASSED + diehard_rank_32x32| 0| 40000| 100|0.93312610| PASSED + diehard_rank_6x8| 0| 100000| 100|0.83502820| PASSED + diehard_bitstream| 0| 2097152| 100|0.47558461| PASSED + diehard_opso| 0| 2097152| 100|0.83393107| PASSED + diehard_oqso| 0| 2097152| 100|0.17085818| PASSED + diehard_dna| 0| 2097152| 100|0.95316222| PASSED +diehard_count_1s_str| 0| 256000| 100|0.58772531| PASSED +diehard_count_1s_byt| 0| 256000| 100|0.92622543| PASSED + diehard_parking_lot| 0| 12000| 100|0.24541775| PASSED + diehard_2dsphere| 2| 8000| 100|0.82051329| PASSED + diehard_3dsphere| 3| 4000| 100|0.16939087| PASSED + diehard_squeeze| 0| 100000| 100|0.26180585| PASSED + diehard_sums| 0| 100| 100|0.00131414| WEAK + diehard_sums| 0| 100| 200|0.00019033| WEAK + diehard_sums| 0| 100| 300|0.00001845| WEAK + diehard_sums| 0| 100| 400|0.00000274| WEAK + diehard_sums| 0| 100| 500|0.00000146| WEAK + diehard_sums| 0| 100| 600|0.00000518| WEAK + diehard_sums| 0| 100| 700|0.00000120| WEAK + diehard_sums| 0| 100| 800|0.00000136| WEAK + diehard_sums| 0| 100| 900|0.00000164| WEAK + diehard_sums| 0| 100| 1000|0.00000038| FAILED + diehard_runs| 0| 100000| 100|0.90697557| PASSED + diehard_runs| 0| 100000| 100|0.46492407| PASSED + diehard_craps| 0| 200000| 100|0.08890164| PASSED + diehard_craps| 0| 200000| 100|0.68877459| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.65830948| PASSED + marsaglia_tsang_gcd| 0| 10000000| 100|0.55949006| PASSED + sts_monobit| 1| 100000| 100|0.91014347| PASSED + sts_runs| 2| 100000| 100|0.46023787| PASSED + sts_serial| 1| 100000| 100|0.37938157| PASSED + sts_serial| 2| 100000| 100|0.79494593| PASSED + sts_serial| 3| 100000| 100|0.25702001| PASSED + sts_serial| 3| 100000| 100|0.56670546| PASSED + sts_serial| 4| 100000| 100|0.83700449| PASSED + sts_serial| 4| 100000| 100|0.15880323| PASSED + sts_serial| 5| 100000| 100|0.73026691| PASSED + sts_serial| 5| 100000| 100|0.79324799| PASSED + sts_serial| 6| 100000| 100|0.12893514| PASSED + sts_serial| 6| 100000| 100|0.43885054| PASSED + sts_serial| 7| 100000| 100|0.58482440| PASSED + sts_serial| 7| 100000| 100|0.59704969| PASSED + sts_serial| 8| 100000| 100|0.17431467| PASSED + sts_serial| 8| 100000| 100|0.88757904| PASSED + sts_serial| 9| 100000| 100|0.29214774| PASSED + sts_serial| 9| 100000| 100|0.21963552| PASSED + sts_serial| 10| 100000| 100|0.97034591| PASSED + sts_serial| 10| 100000| 100|0.68185135| PASSED + sts_serial| 11| 100000| 100|0.44262494| PASSED + sts_serial| 11| 100000| 100|0.60229032| PASSED + sts_serial| 12| 100000| 100|0.60546721| PASSED + sts_serial| 12| 100000| 100|0.68248356| PASSED + sts_serial| 13| 100000| 100|0.70604921| PASSED + sts_serial| 13| 100000| 100|0.33437419| PASSED + sts_serial| 14| 100000| 100|0.76956496| PASSED + sts_serial| 14| 100000| 100|0.45860942| PASSED + sts_serial| 15| 100000| 100|0.99328462| PASSED + sts_serial| 15| 100000| 100|0.27008137| PASSED + sts_serial| 16| 100000| 100|0.77186602| PASSED + sts_serial| 16| 100000| 100|0.95522347| PASSED + rgb_bitdist| 1| 100000| 100|0.65901869| PASSED + rgb_bitdist| 2| 100000| 100|0.96646800| PASSED + rgb_bitdist| 3| 100000| 100|0.56192931| PASSED + rgb_bitdist| 4| 100000| 100|0.71123613| PASSED + rgb_bitdist| 5| 100000| 100|0.60652057| PASSED + rgb_bitdist| 6| 100000| 100|0.40311562| PASSED + rgb_bitdist| 7| 100000| 100|0.94461945| PASSED + rgb_bitdist| 8| 100000| 100|0.94399288| PASSED + rgb_bitdist| 9| 100000| 100|0.18597796| PASSED + rgb_bitdist| 10| 100000| 100|0.16016896| PASSED + rgb_bitdist| 11| 100000| 100|0.43475932| PASSED + rgb_bitdist| 12| 100000| 100|0.99978738| WEAK + rgb_bitdist| 12| 100000| 200|0.68461269| PASSED +rgb_minimum_distance| 2| 10000| 1000|0.16541757| PASSED +rgb_minimum_distance| 3| 10000| 1000|0.24623892| PASSED +rgb_minimum_distance| 4| 10000| 1000|0.01443284| PASSED +rgb_minimum_distance| 5| 10000| 1000|0.11408750| PASSED + rgb_permutations| 2| 100000| 100|0.03121809| PASSED + rgb_permutations| 3| 100000| 100|0.79282729| PASSED + rgb_permutations| 4| 100000| 100|0.86630693| PASSED + rgb_permutations| 5| 100000| 100|0.51763993| PASSED + rgb_lagged_sum| 0| 1000000| 100|0.89857723| PASSED + rgb_lagged_sum| 1| 1000000| 100|0.74404815| PASSED + rgb_lagged_sum| 2| 1000000| 100|0.02292037| PASSED + rgb_lagged_sum| 3| 1000000| 100|0.93288381| PASSED + rgb_lagged_sum| 4| 1000000| 100|0.90626965| PASSED + rgb_lagged_sum| 5| 1000000| 100|0.47551343| PASSED + rgb_lagged_sum| 6| 1000000| 100|0.98593748| PASSED + rgb_lagged_sum| 7| 1000000| 100|0.05946751| PASSED + rgb_lagged_sum| 8| 1000000| 100|0.50416533| PASSED + rgb_lagged_sum| 9| 1000000| 100|0.68245658| PASSED + rgb_lagged_sum| 10| 1000000| 100|0.43373343| PASSED + rgb_lagged_sum| 11| 1000000| 100|0.96109236| PASSED + rgb_lagged_sum| 12| 1000000| 100|0.41697577| PASSED + rgb_lagged_sum| 13| 1000000| 100|0.73468235| PASSED + rgb_lagged_sum| 14| 1000000| 100|0.36902723| PASSED + rgb_lagged_sum| 15| 1000000| 100|0.98028491| PASSED + rgb_lagged_sum| 16| 1000000| 100|0.99078444| PASSED + rgb_lagged_sum| 17| 1000000| 100|0.54349261| PASSED + rgb_lagged_sum| 18| 1000000| 100|0.04822766| PASSED + rgb_lagged_sum| 19| 1000000| 100|0.05522277| PASSED + rgb_lagged_sum| 20| 1000000| 100|0.65230164| PASSED + rgb_lagged_sum| 21| 1000000| 100|0.47670341| PASSED + rgb_lagged_sum| 22| 1000000| 100|0.21627174| PASSED + rgb_lagged_sum| 23| 1000000| 100|0.60489204| PASSED + rgb_lagged_sum| 24| 1000000| 100|0.78484760| PASSED + rgb_lagged_sum| 25| 1000000| 100|0.16596556| PASSED + rgb_lagged_sum| 26| 1000000| 100|0.91582999| PASSED + rgb_lagged_sum| 27| 1000000| 100|0.49254250| PASSED + rgb_lagged_sum| 28| 1000000| 100|0.25321125| PASSED + rgb_lagged_sum| 29| 1000000| 100|0.60415030| PASSED + rgb_lagged_sum| 30| 1000000| 100|0.98270526| PASSED + rgb_lagged_sum| 31| 1000000| 100|0.71498718| PASSED + rgb_lagged_sum| 32| 1000000| 100|0.50196089| PASSED + rgb_kstest_test| 0| 10000| 1000|0.62516898| PASSED + dab_bytedistrib| 0| 51200000| 1|0.57152727| PASSED + dab_dct| 256| 50000| 1|0.59394670| PASSED +Preparing to run test 207. ntuple = 0 + dab_filltree| 32| 15000000| 1|0.17868986| PASSED + dab_filltree| 32| 15000000| 1|0.81965604| PASSED +Preparing to run test 208. ntuple = 0 + dab_filltree2| 0| 5000000| 1|0.36858723| PASSED + dab_filltree2| 1| 5000000| 1|0.62765239| PASSED +Preparing to run test 209. ntuple = 0 + dab_monobit2| 12| 65000000| 1|0.08817873| PASSED +# +# Test duration: 116.67653443753333 minutes +#