use of uk.ac.sussex.gdsc.smlm.fitting.JumpDistanceAnalysis.MixedJumpDistanceCumulFunction in project GDSC-SMLM by aherbert.
the class JumpDistanceAnalysisTest method canIntegrateProbabilityToCumulativeWithMixedPopulation.
@Disabled("Commented out as this test always passes")
@Test
void canIntegrateProbabilityToCumulativeWithMixedPopulation() {
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) {
for (final double f : new double[] { 0, 0.1, 0.2, 0.4, 0.7, 0.9, 1 }) {
final double[] params = new double[] { f, d, 1 - f, d * 0.1 };
final MixedJumpDistanceFunction fp = new MixedJumpDistanceFunction(null, d, 2);
final MixedJumpDistanceCumulFunction fc = new MixedJumpDistanceCumulFunction(null, null, d, 2);
final UnivariateFunction func = new UnivariateFunction() {
@Override
public double value(double x) {
return fp.evaluate(x, params);
}
};
double x = d / 8;
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, f=%.1f : x=%.1f, e=%f, o=%f,
// iter=%d, eval=%d", d, f, x, e, o,
// si.getIterations(), si.getEvaluations());
TestAssertions.assertTest(e, o, equality, FunctionUtils.getSupplier("Failed to integrate: x=%g", x));
}
}
}
}
Aggregations