use of uk.ac.sussex.gdsc.smlm.fitting.JumpDistanceAnalysis.JumpDistanceCumulFunction in project GDSC-SMLM by aherbert.
the class JumpDistanceAnalysisTest method canIntegrateProbabilityToCumulativeWithSinglePopulation.
@Disabled("Commented out as this test always passes")
@Test
void canIntegrateProbabilityToCumulativeWithSinglePopulation() {
final JumpDistanceAnalysis jd = new JumpDistanceAnalysis();
jd.setMinD(0);
jd.setMinFraction(0);
final SimpsonIntegrator si = new SimpsonIntegrator(1e-3, 1e-8, 2, SimpsonIntegrator.SIMPSON_MAX_ITERATIONS_COUNT);
final DoubleDoubleBiPredicate equality = TestHelper.doublesAreClose(1e-2, 0);
for (final double d : D) {
final double[] params = new double[] { d };
final JumpDistanceFunction fp = new JumpDistanceFunction(null, d);
final JumpDistanceCumulFunction fc = new JumpDistanceCumulFunction(null, null, d);
double x = d / 8;
final UnivariateFunction func = new UnivariateFunction() {
@Override
public double value(double x) {
return fp.evaluate(x, params);
}
};
for (int i = 1; i < 10; i++, x *= 2) {
final double e = fc.evaluate(x, params);
// Integrate
final double o = si.integrate(10000, func, 0, x);
// logger.info(FunctionUtils.getSupplier("Integrate d=%.1f : x=%.1f, e=%f, o=%f, iter=%d,
// eval=%d", d, x, e, o, si.getIterations(),
// si.getEvaluations());
TestAssertions.assertTest(e, o, equality, FunctionUtils.getSupplier("Failed to integrate: x=%g", x));
}
}
}
Aggregations