Package org.apache.commons.math3.distribution

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


        for (int i = 0; i < 10; i++) {
            quantiles[i] = rdg.nextUniform(0, 1);
        }
        // Reseed again so the inversion generator gets the same sequence
        rg.setSeed(100);
        BetaDistribution betaDistribution = new BetaDistribution(rg, 2, 4,
                                                                 BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY);
        /*
         *  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);
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testNextBeta() {
        double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistribution(2,5));
        long[] counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextBeta(2, 5);
            TestUtils.updateCounts(value, counts, quartiles);
View Full Code Here

     * @param alpha first distribution shape parameter
     * @param beta second distribution shape parameter
     * @return random value sampled from the beta(alpha, beta) distribution
     */
    public double nextBeta(double alpha, double beta) {
        return new BetaDistribution(getRandomGenerator(), alpha, beta,
                BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
    }
View Full Code Here

        }
        if (betaDistributionBeta < 0) {
            throw new IllegalArgumentException("The betaDistributionBeta (" + betaDistributionBeta
                    + ") must be at least 0.");
        }
        betaDistribution = new BetaDistribution(betaDistributionAlpha, betaDistributionBeta);
    }
View Full Code Here

     * @param alpha first distribution shape parameter
     * @param beta second distribution shape parameter
     * @return random value sampled from the beta(alpha, beta) distribution
     */
    public double nextBeta(double alpha, double beta) {
        return new BetaDistribution(getRan(), alpha, beta,
                BetaDistribution.DEFAULT_INVERSE_ABSOLUTE_ACCURACY).sample();
    }
View Full Code Here

        for (int i = 0; i < 10; i++) {
            quantiles[i] = randomData.nextUniform(0, 1);
        }
        // Reseed again so the inversion generator gets the same sequence
        randomData.reSeed(100);
        BetaDistribution betaDistribution = new BetaDistribution(2, 4);
        /*
         *  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 = randomData.nextInversionDeviate(betaDistribution);
            Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testNextBeta() {
        double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistribution(2,5));
        long[] counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextBeta(2, 5);
            TestUtils.updateCounts(value, counts, quartiles);
View Full Code Here

        for (int i = 0; i < 10; i++) {
            quantiles[i] = randomData.nextUniform(0, 1);
        }
        // Reseed again so the inversion generator gets the same sequence
        randomData.reSeed(100);
        BetaDistribution betaDistribution = new BetaDistribution(2, 4);
        /*
         *  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 = randomData.nextInversionDeviate(betaDistribution);
            Assert.assertEquals(betaDistribution.cumulativeProbability(value), quantiles[i], 10E-9);
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testNextBeta() throws Exception {
        double[] quartiles = TestUtils.getDistributionQuartiles(new BetaDistribution(2,5));
        long[] counts = new long[4];
        randomData.reSeed(1000);
        for (int i = 0; i < 1000; i++) {
            double value = randomData.nextBeta(2, 5);
            TestUtils.updateCounts(value, counts, quartiles);
View Full Code Here

                // tests for termination and stringent tolerances
                if (FastMath.abs(actRed) <= TWO_EPS &&
                    preRed <= TWO_EPS &&
                    ratio <= 2.0) {
                    throw new ConvergenceException(LocalizedFormats.TOO_SMALL_COST_RELATIVE_TOLERANCE,
                                                   costRelativeTolerance);
                } else if (delta <= TWO_EPS * xNorm) {
                    throw new ConvergenceException(LocalizedFormats.TOO_SMALL_PARAMETERS_RELATIVE_TOLERANCE,
                                                   parRelativeTolerance);
                } else if (maxCosine <= TWO_EPS) {
                    throw new ConvergenceException(LocalizedFormats.TOO_SMALL_ORTHOGONALITY_TOLERANCE,
                                                   orthoTolerance);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.distribution.BetaDistribution

Copyright © 2018 www.massapicom. 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.