Examples of GammaDistribution

@version $Revision: 920852 $ $Date: 2010-03-09 13:53:44 +0100 (mar. 09 mars 2010) $
  • org.apache.commons.math3.distribution.GammaDistribution
    pedia.org/wiki/Gamma_distribution">Gamma distribution (Wikipedia) @see Gamma distribution (MathWorld)
  • org.jquantlib.math.distributions.GammaDistribution
    pedia.org/wiki/Gamma_distribution">Gamma Distribution @see Gamma Distribution on Wolfram MathWorld @author Richard Gomes @author Dominik Holenstein

  • Examples of org.apache.commons.math3.distribution.GammaDistribution

        public void testNextGamma() {
            double[] quartiles;
            long[] counts;

            // Tests shape > 1, one case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(4, 2));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(4, 2);
                TestUtils.updateCounts(value, counts, quartiles);
            }
            TestUtils.assertChiSquareAccept(expected, counts, 0.001);

            // Tests shape <= 1, another case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(0.3, 3));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(0.3, 3);
                TestUtils.updateCounts(value, counts, quartiles);
    View Full Code Here

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

         * @return random value sampled from the Gamma(shape, scale) distribution
         * @throws NotStrictlyPositiveException if {@code shape <= 0} or
         * {@code scale <= 0}.
         */
        public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException {
            return new GammaDistribution(getRandomGenerator(),shape, scale,
                    GammaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
        }
    View Full Code Here

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

         * @return random value sampled from the Gamma(shape, scale) distribution
         * @throws NotStrictlyPositiveException if {@code shape <= 0} or
         * {@code scale <= 0}.
         */
        public double nextGamma(double shape, double scale) throws NotStrictlyPositiveException {
            return new GammaDistribution(getRan(),shape, scale,
                    GammaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
        }
    View Full Code Here

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

        public void testNextGamma() {
            double[] quartiles;
            long[] counts;

            // Tests shape > 1, one case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(4, 2));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(4, 2);
                TestUtils.updateCounts(value, counts, quartiles);
            }
            TestUtils.assertChiSquareAccept(expected, counts, 0.001);

            // Tests shape <= 1, another case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(0.3, 3));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(0.3, 3);
                TestUtils.updateCounts(value, counts, quartiles);
    View Full Code Here

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

                assertEquals(x3, r.get("v3").get("value").asDouble(), 0);
            }

            // now compare against reference distributions to test accuracy of the observed step distributions
            NormalDistribution normalDistribution = new NormalDistribution();
            GammaDistribution gd1 = new GammaDistribution(0.2, 5);
            GammaDistribution gd2 = new GammaDistribution(1, 1);
            TDistribution tDistribution = new TDistribution(2);
            for (double q : new double[]{0.001, 0.01, 0.1, 0.2, 0.5, 0.8, 0.9, 0.99, 0.99}) {
                double uG1 = gd1.cumulativeProbability(tdG1.quantile(q));
                assertEquals(q, uG1, (1 - q) * q * 10e-2);

                double uG2 = gd2.cumulativeProbability(tdG2.quantile(q));
                assertEquals(q, uG2, (1 - q) * q * 10e-2);

                double u1 = normalDistribution.cumulativeProbability(td1.quantile(q));
                assertEquals(q, u1, (1 - q) * q * 10e-2);

     
    View Full Code Here

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

        public void testNextGamma() throws Exception {
            double[] quartiles;
            long[] counts;

            // Tests shape > 1, one case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(4, 2));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(4, 2);
                TestUtils.updateCounts(value, counts, quartiles);
            }
            TestUtils.assertChiSquareAccept(expected, counts, 0.001);

            // Tests shape <= 1, another case in the rejection sampling
            quartiles = TestUtils.getDistributionQuartiles(new GammaDistribution(0.3, 3));
            counts = new long[4];
            randomData.reSeed(1000);
            for (int i = 0; i < 1000; i++) {
                double value = randomData.nextGamma(0.3, 3);
                TestUtils.updateCounts(value, counts, quartiles);
    View Full Code Here

    Examples of org.jquantlib.math.distributions.GammaDistribution

                      {14.0, 7.665444025768806E-9},
                      {15.0, 2.659774281674882E-9}};

        // Test for a = 1.0 (alpha)
        double a = 1.0;
        final GammaDistribution gammDistribution = new GammaDistribution(a);
        for (final double[] testvalue : testvalues) {
          final double expected = testvalue[1];
          final double x = testvalue[0];
          final double computed = gammDistribution.op(x);
          // QL.info(computed); // for testing
          final double tolerance = 1.0e-15;
          if (Math.abs(expected-computed)>tolerance) {
            fail("x: " + x + " expected: " + expected + " realised: " + computed);
          }
        }

        // Test for a = 0.1 (alpha)
        a = 0.1;
        final GammaDistribution gammDist = new GammaDistribution(a);
        for (final double[] element : testvalues2) {
          final double expected = element[1];
          final double x = element[0];
          final double computed = gammDist.op(x);
          // QL.info(computed); // for testing
          final double tolerance = 1.0e-15;
          if (Math.abs(expected-computed)>tolerance) {
            fail("x: " + x + " expected: " + expected + " realised: " + computed);
          }
    View Full Code Here

    Examples of org.jquantlib.math.distributions.GammaDistribution

              return cpd.op(k);

          }

              public static double evaluateGammaDistribution(double a, double x) {
                  GammaDistribution gd = new GammaDistribution(a);
                  return gd.op(x);
              }
    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.