use of uk.ac.sussex.gdsc.smlm.function.FixedNonLinearFunction in project GDSC-SMLM by aherbert.
the class MaximumLikelihoodFitter method computeObservedLogLikelihood.
@Override
protected double computeObservedLogLikelihood(double[] y, double[] a) {
if (lastY != null) {
final int n = y.length;
// The function value must be scaled to the expected value of a Poisson process.
double[] scaledy;
if (alpha != 0) {
scaledy = new double[n];
for (int i = n; i-- > 0; ) {
scaledy[i] = y[i] * alpha;
}
} else {
scaledy = y;
}
final LikelihoodWrapper maximumLikelihoodFunction = createLikelihoodWrapper(new FixedNonLinearFunction(scaledy), n, lastY, a);
final double l = maximumLikelihoodFunction.likelihood(a);
if (l == Double.POSITIVE_INFINITY) {
return Double.NEGATIVE_INFINITY;
}
// Reverse negative log likelihood for maximum likelihood score
value = -l;
}
throw new IllegalStateException();
}
Aggregations