Examples of ExponentialDistribution


Examples of org.apache.commons.math3.distribution.ExponentialDistribution

            try
            {
                String[] bounds = params.get(0).split("\\.\\.+");
                final long min = Long.parseLong(bounds[0]);
                final long max = Long.parseLong(bounds[1]);
                ExponentialDistribution findBounds = new ExponentialDistribution(1d);
                // max probability should be roughly equal to accuracy of (max-min) to ensure all values are visitable,
                // over entire range, but this results in overly skewed distribution, so take sqrt
                final double mean = (max - min) / findBounds.inverseCumulativeProbability(1d - Math.sqrt(1d/(max-min)));
                return new ExpFactory(min, max, mean);
            } catch (Exception _)
            {
                throw new IllegalArgumentException("Invalid parameter list for uniform distribution: " + params);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new ExponentialDistribution(mean), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

            try
            {
                String[] bounds = params.get(0).split("\\.\\.+");
                final long min = parseLong(bounds[0]);
                final long max = parseLong(bounds[1]);
                ExponentialDistribution findBounds = new ExponentialDistribution(1d);
                // max probability should be roughly equal to accuracy of (max-min) to ensure all values are visitable,
                // over entire range, but this results in overly skewed distribution, so take sqrt
                final double mean = (max - min) / findBounds.inverseCumulativeProbability(1d - Math.sqrt(1d/(max-min)));
                return new ExpFactory(min, max, mean);
            } catch (Exception e)
            {
                throw new IllegalArgumentException("Invalid parameter list for uniform distribution: " + params);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new ExponentialDistribution(new JDKRandomGenerator(), mean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

            try
            {
                String[] bounds = params.get(0).split("\\.\\.+");
                final long min = parseLong(bounds[0]);
                final long max = parseLong(bounds[1]);
                ExponentialDistribution findBounds = new ExponentialDistribution(1d);
                // max probability should be roughly equal to accuracy of (max-min) to ensure all values are visitable,
                // over entire range, but this results in overly skewed distribution, so take sqrt
                final double mean = (max - min) / findBounds.inverseCumulativeProbability(1d - Math.sqrt(1d/(max-min)));
                return new ExpFactory(min, max, mean);
            } catch (Exception _)
            {
                throw new IllegalArgumentException("Invalid parameter list for uniform distribution: " + params);
            }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

        }

        @Override
        public Distribution get()
        {
            return new DistributionOffsetApache(new ExponentialDistribution(new JDKRandomGenerator(), mean, ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY), min, max);
        }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

     * sampling from the exponential and normal distributions.
     * Communications of the ACM, 15, 873-882.
     * </p>
     */
    public double nextExponential(double mean) throws NotStrictlyPositiveException {
        return new ExponentialDistribution(getRan(), mean,
                ExponentialDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
    }
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

         */
        double[] quartiles;
        long[] counts;

        // Mean 1
        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(1));
        counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextExponential(1);
            TestUtils.updateCounts(value, counts, quartiles);
        }
        TestUtils.assertChiSquareAccept(expected, counts, 0.001);

        // Mean 5
        quartiles = TestUtils.getDistributionQuartiles(new ExponentialDistribution(5));
        counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextExponential(5);
            TestUtils.updateCounts(value, counts, quartiles);
View Full Code Here

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

    // TODO check the rounding behavior
  }

  static Times generateTimes(RandomGenerator rng, double intensity) {
    final ExponentialDistribution ed = new ExponentialDistribution(
        1000d / intensity);
    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

Examples of org.apache.commons.math3.distribution.ExponentialDistribution

  @Override
  @Deprecated
  public ImmutableList<Double> generate(RandomGenerator rng) {
    // we model the announcements as a Poisson process, which means that
    // the interarrival times are exponentially distributed.
    final ExponentialDistribution ed = new ExponentialDistribution(1d / gai);
    ed.reseedRandomGenerator(rng.nextLong());
    double sum = 0;
    final List<Double> arrivalTimes = newArrayList();
    while (sum < length) {
      // final long nt = DoubleMath
      // .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
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.