pyfli.analysis.stat_tests#

Compare simulated and experimental FLI/FLIM distributions with classical and multivariate tests.

This module belongs to pyfli.analysis and is part of PyFLI post-processing, diagnostics, statistical comparison, and result-loading utilities for fitted FLI/FLIM datasets. Public API includes classes TestStat and FLIDistributionTest.

Classes

FLIDistributionTest(sim_batch, exp_batch[, eps])

Run the flidistribution test routine.

TestStat(sim_batch, exp_batch[, eps])

Run the test stat routine.

class TestStat(sim_batch, exp_batch, eps=1e-12)[source]#

Bases: object

Run the test stat routine. batches. The class groups Anderson-Darling, Kolmogorov-Smirnov, likelihood-ratio, bootstrap confidence interval, and Bayesian evidence helpers behind one object.

Parameters:
  • sim_batch (np.ndarray) – Simulated result batch used as the reference distribution.

  • exp_batch (np.ndarray) – Experimental result batch used for comparison.

  • eps (float) – Small numerical tolerance used to avoid division-by-zero and boundary issues.

anderson_darling()[source]#

Batch AD statistic (two-sample version approximation)

Return type:

ndarray

kolmogorov_smirnov()[source]#

Run the kolmogorov smirnov routine.

Returns:

Kolmogorov-Smirnov statistic and p-value for the supplied samples.

Return type:

np.ndarray

likelihood_ratio()[source]#

Poisson likelihood ratio: Λ = 2 (LL_bi - LL_mono)

Assumes sim_batch = biexp model exp_batch = data

Return type:

Any

bootstrap_ci(metric_func, n_boot=200)[source]#

Generic bootstrap CI over batch

Parameters:
Return type:

tuple[Any, …]

bayesian_evidence(k_mono=2, k_bi=4)[source]#

Approximate log evidence using BIC

Parameters:
Return type:

ndarray

run_all_tests()[source]#

Run all tests.

Returns:

Summary table or array containing the configured statistical test results.

Return type:

np.ndarray

class FLIDistributionTest(sim_batch, exp_batch, eps=1e-12)[source]#

Bases: object

Run the flidistribution test routine. MMD, energy distance, sliced Wasserstein, Frechet-style, and PCA-overlap metrics for validating whether simulations match measured data.

Parameters:
  • sim_batch (np.ndarray) – Simulated result batch used as the reference distribution.

  • exp_batch (np.ndarray) – Experimental result batch used for comparison.

  • eps (float) – Small numerical tolerance used to avoid division-by-zero and boundary issues.

mmd(gamma=None)[source]#

Kernel two-sample test.

Parameters:

gamma (float | None)

Return type:

ndarray

energy_distance()[source]#

Run the energy distance routine.

Returns:

Object produced by energy distance.

Return type:

Any

sliced_wasserstein(n_projections=50)[source]#

Project high-D distributions to random 1D lines.

Parameters:

n_projections (int)

Return type:

ndarray

frechet_distance()[source]#

Run the frechet distance routine.

Returns:

Frechet distance between the supplied curves or point sequences.

Return type:

np.ndarray

pca_overlap(n_components=10)[source]#

Run the PCA overlap routine.

Parameters:

n_components (int) – Number of PCA components retained for the metric.

Returns:

Overlap score between PCA projections of the supplied groups.

Return type:

np.ndarray

run_all()[source]#

Run all.

Returns:

Dictionary containing the data produced by run all.

Return type:

dict[Any, Any]