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

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

Introduction

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

Prototype

public Well1024a() 

Source Link

Document

Creates a new random number generator.

Usage

From source file:com.ibm.bi.dml.runtime.util.PoissonPRNGenerator.java

public void setup(double mean, long sd) {
    seed = sd;/*w  w w . j  ava2s  .  c  om*/

    SynchronizedRandomGenerator srg = new SynchronizedRandomGenerator(new Well1024a());
    srg.setSeed(seed);
    _pdist = new PoissonDistribution(srg, _mean, PoissonDistribution.DEFAULT_EPSILON,
            PoissonDistribution.DEFAULT_MAX_ITERATIONS);
}

From source file:com.milaboratory.core.io.util.AbstractRandomAccessReaderTest.java

@Test
public void test3() throws Exception {
    RandomGenerator rnd = new Well1024a();
    File tempFile = createRandomFile(rnd.nextLong());
    String[] allLines = getAllLines(tempFile);
    for (int step = 5; step < 10; step += 2) {
        for (int start = 1; start <= step; ++start) {
            FileIndex index = buildIndex(tempFile, step, start);
            StringReader reader = new StringReader(index, tempFile);
            for (int i = 0; i < allLines.length; ++i) {
                int p = rnd.nextInt(allLines.length);
                Assert.assertEquals(allLines[p], reader.take(p));
            }//from w  w  w  .  ja  v a2  s . c om
        }
    }
    tempFile.delete();
}

From source file:com.ibm.bi.dml.runtime.matrix.data.LibMatrixDatagen.java

/**
 * A matrix of random numbers is generated by using multiple seeds, one for each 
 * block. Such block-level seeds are produced via Well equidistributed long-period linear 
 * generator (Well1024a). For a given seed, this function sets up the block-level seeds.
 * /*from   w  w w .ja v a2s.c  o m*/
 * This function is invoked from both CP (RandCPInstruction.processInstruction()) 
 * as well as MR (RandMR.java while setting up the Rand job).
 * 
 * @param seed
 * @return
 */
public static Well1024a setupSeedsForRand(long seed) {
    long lSeed = (seed == DataGenOp.UNSPECIFIED_SEED ? DataGenOp.generateRandomSeed() : seed);
    LOG.trace("Setting up RandSeeds with initial seed = " + lSeed + ".");

    Random random = new Random(lSeed);
    Well1024a bigrand = new Well1024a();
    //random.setSeed(lSeed);
    int[] seeds = new int[32];
    for (int s = 0; s < seeds.length; s++)
        seeds[s] = random.nextInt();
    bigrand.setSeed(seeds);

    return bigrand;
}

From source file:com.milaboratory.core.io.sequence.fastq.RandomAccessFastqReaderTest.java

@Test
public void test3() throws Exception {
    File sample = new File(
            SingleFastqReaderTest.class.getClassLoader().getResource("sequences/sample_r1.fastq").toURI());
    RandomGenerator rnd = new Well1024a();
    for (int step = 1; step < 5; ++step) {
        SingleRead[] reads = allReads(sample);
        FileIndex index = buildeIndex(sample, step);
        RandomAccessFastqReader rreader = new RandomAccessFastqReader(sample, index, true);
        for (int i = 0; i < 100; ++i) {
            int p = rnd.nextInt(reads.length);
            SingleRead actual = rreader.take(p);
            Assert.assertEquals(reads[p].getId(), actual.getId());
            Assert.assertEquals(reads[p].getData(), actual.getData());
            Assert.assertEquals(reads[p].getDescription(), actual.getDescription());
        }//  w w w .j a  v a2 s  . co m
    }
}

From source file:org.briljantframework.benchmark.DataFrameSortPerformance.java

@Setup(Level.Iteration)
public void setupDataFrame() {
    DataFrame.Builder builder = new MixedDataFrame.Builder();
    UniformRandomGenerator gen = new UniformRandomGenerator(new Well1024a());
    for (int i = 0; i < 1000_000; i++) {
        builder.setRecord(String.valueOf(i), Vector.of(gen.nextNormalizedDouble(), i, 20.0, 30.0));
    }//w  w w .j  a  v  a2  s.  c  om
    builder.setColumnIndex("First", "Second", "Third", "Fourth");
    dataFrame = builder.build();
}

From source file:org.briljantframework.benchmark.VectorSortPerformance.java

@Setup(Level.Iteration)
public void setupDataFrame() {
    Vector.Builder builder = Vector.Builder.of(Double.class);
    UniformRandomGenerator gen = new UniformRandomGenerator(new Well1024a());
    for (int i = 0; i < 1000_000; i++) {
        builder.add(gen.nextNormalizedDouble());
    }//  ww w .j a  va  2s  .  c o  m
    vector = builder.build();
}

From source file:org.optaplanner.core.impl.solver.random.DefaultRandomFactory.java

@Override
public Random createRandom() {
    switch (randomType) {
    case JDK:/*from w  w w. j  a v  a 2 s  .com*/
        return randomSeed == null ? new Random() : new Random(randomSeed);
    case MERSENNE_TWISTER:
        return new RandomAdaptor(randomSeed == null ? new MersenneTwister() : new MersenneTwister(randomSeed));
    case WELL512A:
        return new RandomAdaptor(randomSeed == null ? new Well512a() : new Well512a(randomSeed));
    case WELL1024A:
        return new RandomAdaptor(randomSeed == null ? new Well1024a() : new Well1024a(randomSeed));
    case WELL19937A:
        return new RandomAdaptor(randomSeed == null ? new Well19937a() : new Well19937a(randomSeed));
    case WELL19937C:
        return new RandomAdaptor(randomSeed == null ? new Well19937c() : new Well19937c(randomSeed));
    case WELL44497A:
        return new RandomAdaptor(randomSeed == null ? new Well44497a() : new Well44497a(randomSeed));
    case WELL44497B:
        return new RandomAdaptor(randomSeed == null ? new Well44497b() : new Well44497b(randomSeed));
    default:
        throw new IllegalStateException("The randomType (" + randomType + ") is not implemented.");
    }
}