Example usage for org.apache.commons.math3.random RandomDataImpl RandomDataImpl

List of usage examples for org.apache.commons.math3.random RandomDataImpl RandomDataImpl

Introduction

In this page you can find the example usage for org.apache.commons.math3.random RandomDataImpl RandomDataImpl.

Prototype

public RandomDataImpl(RandomGenerator rand) 

Source Link

Document

Construct a RandomDataImpl using the supplied RandomGenerator as the source of (non-secure) random data.

Usage

From source file:fi.smaa.common.RandomUtil.java

private RandomUtil(RandomGenerator engine) {
    this.random = new RandomDataImpl(engine);
    this.engine = engine;
}

From source file:cc.redberry.core.combinatorics.IntPriorityPermutationsGeneratorTest.java

@Test
public void test3() {
    final int dimm = 6;
    final int maxPerms = 100;
    RandomDataImpl rd = new RandomDataImpl(new MersenneTwister());
    for (int count = 0; count < 100; ++count) {
        //Generate combinatorics
        int pCount = rd.nextInt(1, maxPerms);
        int[][] permutations = new int[pCount][];
        for (int i = 0; i < pCount; ++i)
            OUTER: while (true) {
                permutations[i] = rd.nextPermutation(dimm, dimm);
                for (int j = 0; j < i; ++j)
                    if (Arrays.equals(permutations[i], permutations[j]))
                        continue OUTER;
                break;
            }//from  w  w w .jav  a  2 s . c  om
        IntPriorityPermutationsGenerator generator = new IntPriorityPermutationsGenerator(dimm);
        //adding priorities
        for (int i = 0; i < pCount; ++i)
            for (int j = 0; j <= pCount - i; ++j) {
                addPriority(generator, permutations[i]);
                generator.reset();
            }

        for (int i = 0; i < pCount; ++i)
            assertTrue(Arrays.equals(permutations[i], generator.take()));
    }
}