use of org.apache.commons.math3.stat.descriptive.rank.Max in project GDSC-SMLM by aherbert.
the class PoissonCalculatorTest method cumulativeProbabilityIsOneWithRealData.
private void cumulativeProbabilityIsOneWithRealData(final double mu, double min, double max, boolean test) {
double p = 0;
UnivariateIntegrator in = new SimpsonIntegrator();
p = in.integrate(20000, new UnivariateFunction() {
public double value(double x) {
double v;
v = PoissonCalculator.likelihood(mu, x);
//System.out.printf("x=%f, v=%f\n", x, v);
return v;
}
}, min, max);
System.out.printf("mu=%f, p=%f\n", mu, p);
if (test) {
Assert.assertEquals(String.format("mu=%f", mu), P_LIMIT, p, 0.02);
}
}
use of org.apache.commons.math3.stat.descriptive.rank.Max in project GDSC-SMLM by aherbert.
the class PoissonCalculatorTest method cumulativeProbabilityIsOneWithRealDataForCountAbove4.
@Test
public void cumulativeProbabilityIsOneWithRealDataForCountAbove4() {
for (double mu : photons) {
// Determine upper limit for a Poisson
double max = new PoissonDistribution(mu).inverseCumulativeProbability(P_LIMIT);
// Determine lower limit
double sd = Math.sqrt(mu);
double min = (int) Math.max(0, mu - 4 * sd);
cumulativeProbabilityIsOneWithRealData(mu, min, max, mu >= 4);
}
}
use of org.apache.commons.math3.stat.descriptive.rank.Max in project GDSC-SMLM by aherbert.
the class PulseActivationAnalysis method createShapes.
private Shape[] createShapes(RandomDataGenerator rdg, int c) {
RandomGenerator rand = rdg.getRandomGenerator();
Shape[] shapes;
double min = sim_size / 20;
double max = sim_size / 10;
double range = max - min;
switch(sim_distribution[c]) {
case CIRCLE:
shapes = new Shape[10];
for (int i = 0; i < shapes.length; i++) {
float x = nextCoordinate(rand);
float y = nextCoordinate(rand);
double radius = rand.nextDouble() * range + min;
shapes[i] = new Circle(x, y, radius);
}
break;
case LINE:
shapes = new Shape[10];
for (int i = 0; i < shapes.length; i++) {
float x = nextCoordinate(rand);
float y = nextCoordinate(rand);
double angle = rand.nextDouble() * Math.PI;
double radius = rand.nextDouble() * range + min;
shapes[i] = new Line(x, y, angle, radius);
}
break;
case POINT:
default:
shapes = new Shape[sim_nMolecules[c]];
for (int i = 0; i < shapes.length; i++) {
float x = nextCoordinate(rand);
float y = nextCoordinate(rand);
shapes[i] = new Point(x, y);
}
}
return shapes;
}
use of org.apache.commons.math3.stat.descriptive.rank.Max in project GDSC-SMLM by aherbert.
the class SCMOSLikelihoodWrapperTest method cumulativeProbabilityIsOneWithRealData.
private void cumulativeProbabilityIsOneWithRealData(final double mu, double min, double max, boolean test) {
double p = 0;
// Test using a standard Poisson-Gaussian convolution
//min = -max;
//final PoissonGaussianFunction pgf = PoissonGaussianFunction.createWithVariance(1, 1, VAR);
UnivariateIntegrator in = new SimpsonIntegrator();
p = in.integrate(20000, new UnivariateFunction() {
public double value(double x) {
double v;
v = SCMOSLikelihoodWrapper.likelihood(mu, VAR, G, O, x);
//System.out.printf("x=%f, v=%f\n", x, v);
return v;
}
}, min, max);
//System.out.printf("mu=%f, p=%f\n", mu, p);
if (test) {
Assert.assertEquals(String.format("mu=%f", mu), P_LIMIT, p, 0.02);
}
}
use of org.apache.commons.math3.stat.descriptive.rank.Max in project GDSC-SMLM by aherbert.
the class SCMOSLikelihoodWrapperTest method cumulativeProbabilityIsOneWithRealDataForCountAbove8.
@Test
public void cumulativeProbabilityIsOneWithRealDataForCountAbove8() {
for (double mu : photons) {
// Determine upper limit for a Poisson
double max = new PoissonDistribution(mu).inverseCumulativeProbability(P_LIMIT);
// Determine lower limit
double sd = Math.sqrt(mu);
double min = (int) Math.max(0, mu - 4 * sd);
// Map to observed values using the gain and offset
max = max * G + O;
min = min * G + O;
cumulativeProbabilityIsOneWithRealData(mu, min, max, mu > 8);
}
}
Aggregations