Skip to content

Diagnostics

mgsl.Failures

Bases: NamedTuple

Solver failure counts per path, always recorded.

Each field is an integer array of shape (n_paths,), summed over all fits of the call. Non-zero counts mean some results rest on unconverged or failed numerics.

Attributes:

Name Type Description
draw_cg_capped array

Residual-draw CG solves that stopped at maxiter: those residuals are too narrow in the directions CG had not reached, and the local ESS of that fit is not computed.

newton_cg_capped array

Newton CG solves that stopped at maxiter (inexact Newton steps; usually harmless if the Newton iteration still converges).

cg_breakdowns array

CG solves stopped by non-positive curvature or non-finite values: the Fisher information is not positive semi-definite or the model returned NaN/inf.

sd_fallbacks array

Newton steps where the CG direction was not a descent direction and steepest descent was used instead.

line_search_failures array

Newton steps where the line search found no decrease although one was predicted.

nonfinite array

Fits whose objective was not finite at the starting centre: the path cannot move ("frozen"), typically NaN data or a log-likelihood undefined there.

from_stats(stats) staticmethod

From stats with leading axis paths (and any further axes, summed over).

totals()

Counts summed over paths.

warn(where)

Issue a warning listing the non-zero counts, with what to check for each.

mgsl.MGSLDiagnostics dataclass

Per-path diagnostics of a run (numpy arrays only).

Attributes:

Name Type Description
taus ndarray

(n_steps,): the observation time of each step's fit.

tau_end float

Observation time reached after the last step.

ess_fraction ndarray

(n_paths, n_steps), see :class:FitDiagnostics. Over tau, per path, it sits near its floor early on and rises to 1 once the local Gaussian approximation becomes accurate; the convergence check is the tau at which the paths all reach 1 together, which the final tau should be beyond.

newton_iter ndarray

(n_paths, n_steps).

cg_newton, cg_draws CGStats

Fields of shape (n_paths, n_steps).

terminal FitDiagnostics or None

The terminal fit at tau_end that produced the samples (fields of shape (n_paths,)), if the run was finalised.

concatenate(a, b) staticmethod

Join a run and its continuation along the step axis (terminal taken from b).

mgsl.FitDiagnostics

Bases: NamedTuple

Diagnostics of a set of local fits (arrays with leading axis paths).

Attributes:

Name Type Description
ess_fraction array

Effective sample size ESS of the fit's m = 2 n_samples_mgvi mirrored residuals as importance samples of the localising distribution, rescaled to (ESS - 1) / (m - 1): 1 means equal weights (the local Gaussian matches the localising distribution at these points), 0 means one point carries all the weight. With few residuals it is a coarse check: deviations of the local Gaussian that the m points do not probe go unseen. NaN where a residual's CG solve did not converge.

newton_iter array

Newton steps taken per fit (all rounds).

cg_newton, cg_draws CGStats

Newton and residual-draw CG statistics.

mgsl.CGStats

Bases: NamedTuple

Statistics of the CG solves of each fit (arrays shaped like the fits).

Attributes:

Name Type Description
mean_iter, max_iter array

Mean and maximum iterations per solve.

max_rel_residual array

Largest |b - A x| / |b| of the unpreconditioned system.

cap_fraction array

Fraction of solves that stopped at maxiter.