use of uk.ac.sussex.gdsc.smlm.math3.distribution.PoissonDistribution in project GDSC-SMLM by aherbert.
the class PoissonCalculatorTest method canComputeLikelihoodForIntegerData.
@Test
void canComputeLikelihoodForIntegerData() {
final DoubleDoubleBiPredicate predicate = TestHelper.doublesAreClose(1e-10, 0);
for (final double u : photons) {
final PoissonDistribution pd = new PoissonDistribution(u);
for (int x = 0; x < 100; x++) {
double expected = pd.probability(x);
double observed = PoissonCalculator.likelihood(u, x);
if (expected > 1e-100) {
TestAssertions.assertTest(expected, observed, predicate);
}
expected = pd.logProbability(x);
observed = PoissonCalculator.logLikelihood(u, x);
TestAssertions.assertTest(expected, observed, predicate);
}
}
}
use of uk.ac.sussex.gdsc.smlm.math3.distribution.PoissonDistribution in project GDSC-SMLM by aherbert.
the class PoissonGaussianFisherInformation method computeLimit.
/**
* Compute the limit of a usable probability above 0.
*
* <p>Find the point where probability will return above 0. Using StdMath.exp this is -746.
* However sub-normal output occurs at -709. This is a good limit for computation.
*
* @param mean the mean
* @return the limit
*/
public static int computeLimit(double mean) {
final PoissonDistribution pd = new PoissonDistribution(mean);
int x = (int) mean;
while (pd.logProbability(x + 1) > -709) {
x++;
}
return x;
}
Aggregations