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