use of uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore in project GDSC-SMLM by aherbert.
the class LseLvmSteppingFunctionSolver method computeDeviationsAndValues.
@Override
protected void computeDeviationsAndValues(double[] parametersVariance, double[] fx) {
Gradient1Function f1 = (Gradient1Function) this.function;
// Capture the y-values if necessary
if (fx != null && fx.length == f1.size()) {
f1 = new Gradient2FunctionValueStore(f1, fx);
}
final LsqVarianceGradientProcedure p = createVarianceProcedure(f1);
if (p.variance(null) == LsqVarianceGradientProcedure.STATUS_OK) {
setDeviations(parametersVariance, p.variance);
}
}
use of uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore in project GDSC-SMLM by aherbert.
the class FastMleSteppingFunctionSolver method computeLastFisherInformationMatrix.
@Override
protected FisherInformationMatrix computeLastFisherInformationMatrix(double[] fx) {
Gradient2Function f2 = (Gradient2Function) function;
// Capture the y-values if necessary
if (fx != null && fx.length == f2.size()) {
f2 = new Gradient2FunctionValueStore(f2, fx);
}
// Add the weights if necessary
if (obsVariances != null) {
f2 = OffsetGradient2Function.wrapGradient2Function(f2, obsVariances);
}
// The fisher information is that for a Poisson process
final PoissonGradientProcedure p = PoissonGradientProcedureUtils.create(f2);
initialiseAndRun(p);
if (p.isNaNGradients()) {
throw new FunctionSolverException(FitStatus.INVALID_GRADIENTS);
}
return new FisherInformationMatrix(p.getLinear(), p.numberOfGradients);
}
use of uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore in project GDSC-SMLM by aherbert.
the class MleLvmSteppingFunctionSolver method computeLastFisherInformationMatrix.
@Override
protected FisherInformationMatrix computeLastFisherInformationMatrix(double[] fx) {
// The Hessian matrix refers to the log-likelihood ratio.
// Compute and invert a matrix related to the Poisson log-likelihood.
// This assumes this does achieve the maximum likelihood estimate for a
// Poisson process.
Gradient1Function localF1 = (Gradient1Function) function;
// Capture the y-values if necessary
if (fx != null && fx.length == localF1.size()) {
localF1 = new Gradient2FunctionValueStore(localF1, fx);
}
// Add the weights if necessary
if (weights != null) {
localF1 = OffsetGradient1Function.wrapGradient1Function(localF1, weights);
}
final PoissonGradientProcedure p = PoissonGradientProcedureUtils.create(localF1);
p.computeFisherInformation(lastA);
if (p.isNaNGradients()) {
throw new FunctionSolverException(FitStatus.INVALID_GRADIENTS);
}
// Re-use space
p.getLinear(walpha);
return new FisherInformationMatrix(walpha, beta.length);
}
Aggregations