pyfli.simulator.calibration.coverage#
Check that the experimental data lies within what the calibrated simulator produces.
Functions
|
Which side of the lifetime range is uncovered, as fractions |
|
Fractions of experimental values below / above the simulated [q, 1 - q] range. |
|
Discrete: stretch |
|
Fraction of experimental pixels inside the region populated by the simulation, per statistic. |
|
Per experimental pixel and statistic: is it inside the region holding |
|
Widen |
|
Move a Beta toward Beta(1, 1) on the same support: shape -> 1 + factor * (shape - 1). |
|
|
|
2D points |
|
Photon prior re-derived from the observed photon counts (or peaks) of the experiment. |
|
The same mean and SD expressed as a Beta on the new support |
|
Flattening factor for one step: large steps far below the target, small steps near it. |
|
Extend |
|
One widening step for every failing statistic; returns the new state and what was changed. |
- hdr_covered(e, s, q=1e-3, bins=120)[source]#
2D points
einside the highest-density region that holds1 - qof the simulated pointss. The simulated density is a binned Gaussian kernel estimate with Scott’s bandwidth (sd * n ** (-1/6)per axis), so the region converges as the number of simulated pixels grows instead of depending on it, unlike a raw cell-count rule, which marks sparse but supported regions as uncovered.
- covered_pixels(exp_stats, sim_stats, q=1e-3)[source]#
Per experimental pixel and statistic: is it inside the region holding
1 - qof the simulated pixels? Raw phasors use the 2D highest-density region (hdr_covered()); photons, edge and background use the central[q, 1 - q]quantile range.
- coverage_fractions(exp_stats, sim_stats, q=1e-3)[source]#
Fraction of experimental pixels inside the region populated by the simulation, per statistic.
- flatten_beta(p, factor)[source]#
Move a Beta toward Beta(1, 1) on the same support: shape -> 1 + factor * (shape - 1).
- resupport_beta(p, lo, hi)[source]#
The same mean and SD expressed as a Beta on the new support
[lo, hi].
- cover_photon_range(state, exp_counts, n_active_bins, margin=0.2, active_fraction=1.0)[source]#
Discrete: stretch
n_cyclesso that the signal photons of every experimental pixel are reachable, given that onlyactive_fractionof them land in active bins.- Parameters:
state (CalibrationState)
exp_counts (ndarray)
n_active_bins (int)
margin (float)
active_fraction (float)
- Return type:
- stretch_tau2_support(state, below, above, step=0.15)[source]#
Extend
tau2_beta_rangeon the side(s) where experimental phasors are uncovered.- Parameters:
state (CalibrationState)
below (float)
above (float)
step (float)
- Return type:
- step_factor(coverage, target, slowest=0.9, fastest=0.4)[source]#
Flattening factor for one step: large steps far below the target, small steps near it.
- refit_photon_prior(state, ctx, exp_counts)[source]#
Photon prior re-derived from the observed photon counts (or peaks) of the experiment.
- Parameters:
state (CalibrationState)
ctx (ObjectiveContext)
exp_counts (ndarray)
- Return type:
- widen(state, failing, exp_stats, sim_stats, ctx, exp_counts, cov, target, photon_refitted)[source]#
One widening step for every failing statistic; returns the new state and what was changed.
- Parameters:
state (CalibrationState)
exp_stats (dict)
sim_stats (dict)
ctx (ObjectiveContext)
exp_counts (ndarray)
cov (dict)
target (float)
photon_refitted (bool)
- Return type:
- ensure_coverage(state, ctx, exp_stats, exp_counts, target=0.99, n_sim=20000, max_iter=10, seed=0)[source]#
Widen
stateuntil every statistic inCOVERAGE_STATScovers at leasttargetof the experimental pixels (ormax_iterwidening steps were made).Returns
(state, trace, coverage, sim, sim_stats);tracehas one row per iteration with the coverage of each statistic, the distance to the experiment and the widening applied.- Parameters:
state (CalibrationState)
ctx (ObjectiveContext)
exp_stats (dict)
exp_counts (ndarray)
target (float)
n_sim (int)
max_iter (int)
seed (int)
- Return type: