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);
}
}