Package org.apache.commons.math3.distribution

Examples of org.apache.commons.math3.distribution.UniformRealDistribution.sample()


         *  Generate a sequence of deviates using inversion - the distribution function
         *  evaluated at the random value from the distribution should match the uniform
         *  random value used to generate it, which is stored in the quantiles[] array.
         */
        for (int i = 0; i < 10; i++) {
            double value = betaDistribution.sample();
            Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
        }
    }

    @Test
View Full Code Here


         *  Generate a sequence of deviates using inversion - the distribution function
         *  evaluated at the random value from the distribution should match the uniform
         *  random value used to generate it, which is stored in the quantiles[] array.
         */
        for (int i = 0; i < 10; i++) {
            double value = betaDistribution.sample();
            Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
        }
    }

    @Test
View Full Code Here

         *  Generate a sequence of deviates using inversion - the distribution function
         *  evaluated at the random value from the distribution should match the uniform
         *  random value used to generate it, which is stored in the quantiles[] array.
         */
        for (int i = 0; i < 10; i++) {
            double value = betaDistribution.sample();
            Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
        }
    }

    @Test
View Full Code Here

    ed.reseedRandomGenerator(rng.nextLong());
    final List<Long> times = newArrayList();

    long sum = 0;
    while (sum < 1000) {
      sum += DoubleMath.roundToLong(ed.sample(), RoundingMode.HALF_DOWN);
      if (sum < 1000) {
        times.add(sum);
      }
    }
    return asTimes(1000, times);
View Full Code Here

      // .roundToLong(ed.sample() * 60d, RoundingMode.HALF_DOWN);

      // ignore values which are smaller than the time unit (one
      // minute), unless its the first value.
      // if (/*nt > 0 ||*/ arrivalTimes.isEmpty()) {
      sum += ed.sample() * 60d;
      if (sum < length) {
        arrivalTimes.add(sum);
      } else if (arrivalTimes.isEmpty()) {
        // there is a small probability where the first
        // generated arrival time is greater than length. This
View Full Code Here

        ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
    double sum = 0d;

    final ImmutableList.Builder<Double> builder = ImmutableList.builder();
    while (sum < length) {
      sum += ed.sample();
      if (sum < length && rng.nextDouble() <= (lambd.apply(sum) / lambdaMax)) {
        builder.add(sum);
      }
    }
    return builder.build();
View Full Code Here

        ResizableDoubleArray eDA2 = new ResizableDoubleArray(2);
        Assert.assertEquals("Initial number of elements should be 0", 0, eDA2.getNumElements());

        final IntegerDistribution randomData = new UniformIntegerDistribution(100, 1000);
        final int iterations = randomData.sample();

        for( int i = 0; i < iterations; i++) {
            eDA2.addElement( i );
        }
View Full Code Here

        ResizableDoubleArray eDA3 = new ResizableDoubleArray(3, 3.0, 3.5);
        Assert.assertEquals("Initial number of elements should be 0", 0, eDA3.getNumElements() );

        final IntegerDistribution randomData = new UniformIntegerDistribution(100, 3000);
        final int iterations = randomData.sample();

        for( int i = 0; i < iterations; i++) {
            eDA3.addElement( i );
        }
View Full Code Here

        // Fill weights array with random int values between 1 and 5
        int[] intWeights = new int[len];
        final IntegerDistribution weightDist = new UniformIntegerDistribution(1, 5);
        for (int i = 0; i < len; i++) {
            intWeights[i] = weightDist.sample();
            weights[i] = intWeights[i];
        }

        // Fill values array with random data from N(mu, sigma)
        // and fill valuesList with values from values array with
View Full Code Here

    LongPrimitiveIterator keyIterator = vectors.keySetIterator();
    Node[][] map = new Node[mapSize][mapSize];
    for (Node[] mapRow : map) {
      for (int j = 0; j < mapSize; j++) {
        if (pascalDistribution != null) {
          keyIterator.skip(pascalDistribution.sample());
        }
        while (!keyIterator.hasNext()) {
          keyIterator = vectors.keySetIterator(); // Start over, a little imprecise but affects it not much
          Preconditions.checkState(keyIterator.hasNext());
          if (pascalDistribution != null) {
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.