mixle.doe.propagate module¶
Forward uncertainty propagation: push an input distribution through a model to output statistics.
Given input uncertainty (a Gaussian or a sampler) and a model f, report the induced uncertainty on
the output – mean, standard deviation, and quantiles. Monte Carlo is general; the unscented transform
propagates the first two moments with 2d+1 deterministic sigma points (exact for a linear model, a
useful low-cost approximation for mild nonlinearity). The back half of the UQ loop, after sensitivity.
- propagate(func, mean, cov=None, *, n=10000, method='montecarlo', quantiles=(0.05, 0.5, 0.95), seed=0)[source]
Propagate a Gaussian input
N(mean, cov)throughfuncto output statistics.- Parameters:
func (Callable[[ndarray], ndarray]) – a vectorized model
f(X) -> ymapping(m, d)inputs to(m,)(or(m, k)) outputs.mean (ndarray) – length-
dinput mean.cov:(d, d)input covariance (defaults to identity).n (int) – Monte Carlo sample size (ignored by the unscented method).
method (str) –
'montecarlo'(sample + summarize, gives quantiles) or'unscented'(sigma-point moment propagation, mean + std only). Looked up through the propagator registry.quantiles (tuple[float, ...]) – output quantiles to report (Monte Carlo only).
cov (ndarray | None)
seed (int)
- Returns:
{'mean', 'std', 'quantiles' (mc only), 'samples' (mc only)}.- Raises:
ValueError – if
meanis non-finite,cov’s shape doesn’t matchmean,covis not a valid (finite, PSD-within-tolerance) covariance,nis not a positive integer, anyquantilesentry is outside[0, 1], ormethodis not registered.- Return type:
- register_propagator(name)[source]
Decorator registering a propagation method under
nameforpropagate().The decorated callable receives
(func, mean, cov, *, n, quantiles, seed)(mean/covalready coerced to float arrays) and returns the output-statistics dict.(MXR-080-1901) Registering a name that is already taken raises instead of replacing it. The old
_PROPAGATORS[name] = fnsilently overwrote, so re-registering"montecarlo"(by import order, a name collision between two plugins, or a module imported twice) changed what EVERY existingpropagate(..., method="montecarlo")call in the process returns – the same call site, the same documented method name, different outputs, and nothing anywhere recording the substitution. This is the registry’s only mutation point, so refusing the collision here is enough to make a resolved method name mean one fixed thing for the life of the process. Adding a NEW name is unaffected: that is the extension point and it stays open. To deliberately replace a built-in, delete the existing entry from_PROPAGATORSfirst – an explicit, greppable act rather than an invisible one.
- unscented_transform(func, mean, cov, *, alpha=1e-3, beta=2.0, kappa=0.0)[source]
Propagate
(mean, cov)throughfuncwith the unscented (sigma-point) transform.Returns the output
(mean, covariance). Exact for an affinefunc; for a nonlinear one it captures the mean and covariance to second order with only2d+1evaluations.- Raises:
ValueError – if
meanis non-finite,cov’s shape doesn’t matchmean,covis not a valid covariance (see_safe_cholesky()),alpha/beta/kappaare not finite non-Boolean scalars,alpha <= 0,beta < 0,d + lambda <= 0,func’s return doesn’t have a leading dimension of2d+1(rejected explicitly, not silently reinterpreted via a total-size-only reshape), orfunc’s return or derived covariance is non-finite/invalid.- Parameters:
- Return type: