Package org.apache.commons.math3.random

Examples of org.apache.commons.math3.random.MersenneTwister.nextInt()


    FinalClass fc = new FinalClass.Builder(rng).builder();
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0,10));
    System.out.println(rng.nextInt(0, 10));
    System.out.println(rng.nextInt(0, 10));
//    rg = new Well44497b(11);
//    rng = new RandomDataImpl(rg);
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
View Full Code Here


    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0,10));
    System.out.println(rng.nextInt(0, 10));
    System.out.println(rng.nextInt(0, 10));
//    rg = new Well44497b(11);
//    rng = new RandomDataImpl(rg);
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
    System.out.println(fc.getRNG().nextInt(0, 10));
View Full Code Here

    int[] freq = new int[numberOfElements];
    Arrays.fill(freq, 0);
    int averageFreq = 1000;
    for(int i=0; i<numberOfElements; ++i){
      for(int j=0; j<averageFreq; ++j){
        freq[rng.nextInt(0, upper)]++;
      }
    }
    Arrays.sort(freq);
    ArrayList<Frequency> hist = new ArrayList<Frequency>(100);
    Frequency currentFrequency = new Frequency(-1);
View Full Code Here

public class TestNextInt {
  public static void main(String[] args){
    RandomGenerator rg = new Well44497b();
    RandomDataImpl rng = new RandomDataImpl(rg);
    System.out.println(rng.nextInt(0, 1));
  }
}
View Full Code Here

        int remainingPoints = crossoverPoints;
        int lastIndex = 0;
        for (int i = 0; i < crossoverPoints; i++, remainingPoints--) {
            // select the next crossover point at random
            final int crossoverIndex = 1 + lastIndex + random.nextInt(length - lastIndex - remainingPoints);

            // copy the current segment
            for (int j = lastIndex; j < crossoverIndex; j++) {
                c1.add(parent1Rep.get(j));
                c2.add(parent2Rep.get(j));
View Full Code Here

        final Set<T> child1Set = new HashSet<T>(length);
        final Set<T> child2Set = new HashSet<T>(length);

        final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
        // choose random points, making sure that lb < ub.
        int a = random.nextInt(length);
        int b;
        do {
            b = random.nextInt(length);
        } while (a == b);
        // determine the lower and upper bounds
View Full Code Here

        final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();
        // choose random points, making sure that lb < ub.
        int a = random.nextInt(length);
        int b;
        do {
            b = random.nextInt(length);
        } while (a == b);
        // determine the lower and upper bounds
        final int lb = FastMath.min(a, b);
        final int ub = FastMath.max(a, b);
View Full Code Here

    @Test
    public void testFloorDivModInt() {
        RandomGenerator generator = new Well1024a(0x7ccab45edeaab90al);
        for (int i = 0; i < 10000; ++i) {
            int a = generator.nextInt();
            int b = generator.nextInt();
            if (b == 0) {
                try {
                    FastMath.floorDiv(a, b);
                    Assert.fail("an exception should have been thrown");
View Full Code Here

    @Test
    public void testFloorDivModInt() {
        RandomGenerator generator = new Well1024a(0x7ccab45edeaab90al);
        for (int i = 0; i < 10000; ++i) {
            int a = generator.nextInt();
            int b = generator.nextInt();
            if (b == 0) {
                try {
                    FastMath.floorDiv(a, b);
                    Assert.fail("an exception should have been thrown");
                } catch (MathArithmeticException mae) {
View Full Code Here

            // define the reference sphere we want to compute
            double d = 25 * random.nextDouble();
            double refRadius = 10 * random.nextDouble();
            Vector3D refCenter = new Vector3D(d, new Vector3D(sr.nextVector()));
            // set up a large sample inside the reference sphere
            int nbPoints = random.nextInt(1000);
            List<Vector3D> points = new ArrayList<Vector3D>();
            for (int i = 0; i < nbPoints; ++i) {
                double r = refRadius * random.nextDouble();
                points.add(new Vector3D(1.0, refCenter, r, new Vector3D(sr.nextVector())));
            }
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.