Search in sources :

Example 1 with Gradient2FunctionValueStore

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);
    }
}
Also used : LsqVarianceGradientProcedure(uk.ac.sussex.gdsc.smlm.fitting.nonlinear.gradient.LsqVarianceGradientProcedure) Gradient1Function(uk.ac.sussex.gdsc.smlm.function.Gradient1Function) Gradient2FunctionValueStore(uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore)

Example 2 with Gradient2FunctionValueStore

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);
}
Also used : OffsetGradient2Function(uk.ac.sussex.gdsc.smlm.function.OffsetGradient2Function) Gradient2Function(uk.ac.sussex.gdsc.smlm.function.Gradient2Function) PoissonGradientProcedure(uk.ac.sussex.gdsc.smlm.fitting.nonlinear.gradient.PoissonGradientProcedure) FisherInformationMatrix(uk.ac.sussex.gdsc.smlm.fitting.FisherInformationMatrix) Gradient2FunctionValueStore(uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore)

Example 3 with Gradient2FunctionValueStore

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);
}
Also used : OffsetGradient1Function(uk.ac.sussex.gdsc.smlm.function.OffsetGradient1Function) Gradient1Function(uk.ac.sussex.gdsc.smlm.function.Gradient1Function) PoissonGradientProcedure(uk.ac.sussex.gdsc.smlm.fitting.nonlinear.gradient.PoissonGradientProcedure) FisherInformationMatrix(uk.ac.sussex.gdsc.smlm.fitting.FisherInformationMatrix) Gradient2FunctionValueStore(uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore)

Aggregations

Gradient2FunctionValueStore (uk.ac.sussex.gdsc.smlm.function.Gradient2FunctionValueStore)3 FisherInformationMatrix (uk.ac.sussex.gdsc.smlm.fitting.FisherInformationMatrix)2 PoissonGradientProcedure (uk.ac.sussex.gdsc.smlm.fitting.nonlinear.gradient.PoissonGradientProcedure)2 Gradient1Function (uk.ac.sussex.gdsc.smlm.function.Gradient1Function)2 LsqVarianceGradientProcedure (uk.ac.sussex.gdsc.smlm.fitting.nonlinear.gradient.LsqVarianceGradientProcedure)1 Gradient2Function (uk.ac.sussex.gdsc.smlm.function.Gradient2Function)1 OffsetGradient1Function (uk.ac.sussex.gdsc.smlm.function.OffsetGradient1Function)1 OffsetGradient2Function (uk.ac.sussex.gdsc.smlm.function.OffsetGradient2Function)1