Search in sources :

Example 1 with InverseGaussianDistribution

use of dr.math.distributions.InverseGaussianDistribution in project beast-mcmc by beast-dev.

the class InverseGaussianDistributionTest method testCDFAndQuantile2.

public void testCDFAndQuantile2() {
    final InverseGaussianDistribution f = new InverseGaussianDistribution(1, 1);
    for (double i = 0.01; i < 0.95; i += 0.01) {
        final double y = i;
        BisectionZeroFinder zeroFinder = new BisectionZeroFinder(new OneVariableFunction() {

            public double value(double x) {
                return f.cdf(x) - y;
            }
        }, 0.01, 100);
        zeroFinder.setMaximumIterations(100);
        zeroFinder.evaluate();
        assertEquals(f.quantile(i), zeroFinder.getResult(), 1e-3);
    }
}
Also used : InverseGaussianDistribution(dr.math.distributions.InverseGaussianDistribution) OneVariableFunction(dr.math.interfaces.OneVariableFunction) BisectionZeroFinder(dr.math.iterations.BisectionZeroFinder)

Aggregations

InverseGaussianDistribution (dr.math.distributions.InverseGaussianDistribution)1 OneVariableFunction (dr.math.interfaces.OneVariableFunction)1 BisectionZeroFinder (dr.math.iterations.BisectionZeroFinder)1