Examples of MersenneTwisterRNG


Examples of org.uncommons.maths.random.MersenneTwisterRNG

public class MersenneTwisterRandomInitializer extends RandomInitializerImpl {

    private static final long serialVersionUID = 1L;

    public MersenneTwisterRandomInitializer() {
  super(new MersenneTwisterRNG());
    }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

    public MersenneTwisterRandomInitializer() {
  super(new MersenneTwisterRNG());
    }

    public MersenneTwisterRandomInitializer(float start, float end) {
  super(new MersenneTwisterRNG(), start, end);
    }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

    testSeed = true;
  }

  private Random buildRandom() {
    if (testSeed) {
      return new MersenneTwisterRNG(STANDARD_SEED);
    } else if (fixedSeed == null) {
      return new MersenneTwisterRNG();
    } else {
      return new MersenneTwisterRNG(RandomUtils.longSeedtoBytes(fixedSeed));
    }
  }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

    testSeed = true;
  }

  private Random buildRandom() {
    if (testSeed) {
      return new MersenneTwisterRNG(STANDARD_SEED);
    } else if (fixedSeed == null) {
      // Force use of standard generator, and disallow use of those based on /dev/random since
      // it causes hangs on Ubuntu
      try {
        return new MersenneTwisterRNG(SEED_GENERATOR);
      } catch (SeedException se) {
        // Can't happen
        throw new IllegalStateException(se);
      }
    } else {
      return new MersenneTwisterRNG(RandomUtils.longSeedtoBytes(fixedSeed));
    }
  }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

  /**
   * Test method for {@link org.apache.mahout.ga.watchmaker.cd.CDFitness#get()}.
   */
  public void testGet() {
    int n = 100;
    Random rng = new MersenneTwisterRNG();
    int tp, tn, fp, fn;
    double se, sp;

    for (int nloop = 0; nloop < n; nloop++) {
      tp = rng.nextInt(1000);
      tn = rng.nextInt(1000);
      fp = rng.nextInt(1000);
      fn = rng.nextInt(1000);

      CDFitness fitness = new CDFitness(tp, fp, tn, fn);
      se = ((double) tp) / (tp + fn);
      sp = ((double) tn) / (tn + fp);

View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

  private MockDataSet mock;

  @Override
  protected void setUp() {
    rng = new MersenneTwisterRNG();
    mock = new MockDataSet(rng, 100);
  }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

    Assert.assertTrue("value > max", value <= max);
  }

  @Override
  protected void setUp() {
    rng = new MersenneTwisterRNG();
    mock = new MockDataSet(rng, 50);
  }
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

    // the dataline has all its attributes set to 1d
    DataLine dl = EasyMock.createMock(DataLine.class);
    EasyMock.expect(dl.getAttribut(EasyMock.anyInt())).andReturn(1d).atLeastOnce();
    EasyMock.replay(dl);

    Random rng = new MersenneTwisterRNG();
    for (int nloop = 0; nloop < n; nloop++) {
      mock.categoricalDataset();

      // all weights are 1 (active)
      CDRule rule = new CDRule(0.);
      for (int condInd = 0; condInd < rule.getNbConditions(); condInd++) {
        rule.setW(condInd, 1.);
        rule.setO(condInd, rng.nextBoolean());
        rule.setV(condInd, rng.nextInt(2)); // two categories
      }

      // the condition is true if the operator is == and the values are equal
      // (value==1), or the operator is != and the values are no equal
      // (value==0)
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

   */
  public void testMate1() {
    int maxattributes = 100;
    int maxcrosspnts = 10;
    int n = 100; // repeat this test n times
    Random rng = new MersenneTwisterRNG();

    // Initialize dataset
    DataSet dataset = EasyMock.createMock(DataSet.class);
    DataSet.initialize(dataset);

    for (int nloop = 0; nloop < n; nloop++) {
      // we need at least 2 attributes for the crossover
      // and a label that will be skipped by the rules
      int nbattributes = rng.nextInt(maxattributes) + 3;
      int crosspnts = rng.nextInt(maxcrosspnts) + 1;

      // prepare dataset mock
      EasyMock.reset(dataset);
      EasyMock.expect(dataset.getNbAttributes()).andReturn(nbattributes).times(2);
      EasyMock.replay(dataset);
View Full Code Here

Examples of org.uncommons.maths.random.MersenneTwisterRNG

   */
  public void testMate2() {
    int maxattributes = 100;
    int maxcrosspnts = 10;
    int n = 100; // repeat this test n times
    Random rng = new MersenneTwisterRNG();

    // Initialize dataset
    DataSet dataset = EasyMock.createMock(DataSet.class);
    DataSet.initialize(dataset);

    for (int nloop = 0; nloop < n; nloop++) {
      int nbattributes = rng.nextInt(maxattributes) + 3;
      int crosspnts = rng.nextInt(maxcrosspnts) + 1;
      // in the case of this test crosspnts should be < nbattributes
      if (crosspnts >= nbattributes)
        crosspnts = nbattributes - 1;

      // prepare dataset mock
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.