* across no more than 3 bin boundaries.
*/
@Override
@Test
public void testDensityIntegrals() {
final RealDistribution distribution = makeDistribution();
final double tol = 1.0e-9;
final BaseAbstractUnivariateIntegrator integrator =
new IterativeLegendreGaussIntegrator(5, 1.0e-12, 1.0e-10);
final UnivariateFunction d = new UnivariateFunction() {
public double value(double x) {
return distribution.density(x);
}
};
final double[] lower = {0, 5, 1000, 5001, 9995};
final double[] upper = {5, 12, 1030, 5010, 10000};
for (int i = 1; i < 5; i++) {
Assert.assertEquals(
distribution.cumulativeProbability(
lower[i], upper[i]),
integrator.integrate(
1000000, // Triangle integrals are very slow to converge
d, lower[i], upper[i]), tol);
}