pyfli.solver.mle_fitter#

Extend the base fitter with Poisson and chi-square maximum-likelihood estimators.

This module belongs to pyfli.solver and is part of PyFLI least-squares, maximum- likelihood, CPU, GPU, binned, and global FLI fitting routines. Public API includes classes MLEFLIFitter.

Module Attributes

MLE_WEIGHTINGS

Objectives of MLEFLIFitter.fit_with_estimator() ("poisson" is the default).

Classes

MLEFLIFitter(freq, decay_px, irf_px[, ...])

Extend the base FLI fitter with Poisson, Pearson, and Neyman objective functions.

MLE_WEIGHTINGS = ('poisson', 'pearson', 'neyman', 'none')#

Objectives of MLEFLIFitter.fit_with_estimator() ("poisson" is the default).

class MLEFLIFitter(freq, decay_px, irf_px, white_noise=0.1, guess_plugin=moment_based_guess, custom_funcs=None, shift_method='zero_pad', fit_indices=None)[source]#

Bases: BaseFLIFitter

Extend the base FLI fitter with Poisson, Pearson, and Neyman objective functions. It supports MLE-style fitting, uncertainty extraction from optimizer curvature, and likelihood-based model comparison.

Parameters:
poisson_log_likelihood(params, model_type)[source]#

Standard Poisson MLE (Deviance/C-Statistic).

Parameters:
  • params (Any)

  • model_type (str)

Return type:

Any

pearson_chi_square(params, model_type)[source]#

Pearson’s Chi-square: Weighted by the MODEL [1/y_model].

Parameters:
  • params (Any)

  • model_type (str)

Return type:

ndarray

neyman_chi_square(params, model_type)[source]#

Neyman’s Chi-square: Weighted by the DATA [1/y_data].

Parameters:
  • params (Any)

  • model_type (str)

Return type:

ndarray

unweighted_sum_of_squares(params, model_type)[source]#

Unweighted sum of squared residuals (every gate counts equally).

Parameters:
  • params (Any)

  • model_type (str)

Return type:

ndarray

fit_with_estimator(estimator_type='poisson', p0=None, bounds=None, model_type='bi-exponential', weighting=None, **kwargs)[source]#

Main interface for MLE/Chi-square fitting. Fully compatible with BaseFLIFitter registry and offset-based parameter resolving.

Parameters:
  • estimator_type (str) – Objective name ("poisson", "pearson" or "neyman"); used when weighting is not given. Unknown names fall back to "poisson".

  • p0 (Any) – Initial parameters and bounds (see resolve_params_and_bounds()).

  • bounds (Any) – Initial parameters and bounds (see resolve_params_and_bounds()).

  • model_type (str) – "mono-exponential" or "bi-exponential".

  • weighting (str | None) –

    Objective to minimize (see MLE_WEIGHTINGS); overrides estimator_type:

    • "poisson" (default): Poisson deviance – the maximum-likelihood estimator for photon counts; the consistent, least-biased choice.

    • "pearson": sum (d - mu)^2 / mu minimized directly. Because the weights move with the model, it is biased towards larger model values (for decays, longer lifetimes) at low counts.

    • "neyman": sum (d - mu)^2 / max(d, 1); biased towards low counts (shorter lifetimes) at low counts.

    • "none": unweighted sum of squares.

  • **kwargs (Any) – max_iter (or maxiter, default 2000) optimizer iterations, maxfun (default 50000), ftol and gtol.

Return type:

Any

compare_models(alpha=0.05, estimator='poisson')[source]#

Statistical model selection. - Poisson: Uses Likelihood Ratio Test (LRT) on Deviance. - Chi-square/LS: Uses F-test on the reported chi-square (res[3], the Poisson

deviance from compute_fli_stats).

Parameters:
Return type:

tuple[Any, …]