NonlinearSSM.particle_filter#
- NonlinearSSM.particle_filter(y, *, n_particles=2000, method='bootstrap', ess_threshold=0.5, seed=None)[source]#
Sequential Monte Carlo: the filter that assumes nothing smooth.
The bootstrap filter (Gordon-Salmond-Smith 1993) propagates particles through the transition and reweights by the measurement density, resampling systematically when the effective sample size falls below the stated fraction. The auxiliary variant (Pitt-Shephard 1999) pre-selects particles by where the transition expects them to land – worthwhile when the measurement is informative and the transition is tight enough that the expectation predicts the landing point. When transition noise dominates, the point anchors mispredict, the second-stage weights degenerate, and the bootstrap filter is the better tool; watch the effective sample size. Both return an unbiased estimate of the likelihood; its Monte Carlo noise is real, and seed-to-seed spread is the honest error bar.
Both methods observe the substrate’s initial-state convention: the cloud at the first period is drawn from
N(a_1, P_1)and weighted directly, with no transition applied before the first observation (the auxiliary look-ahead therefore starts at the second).- Parameters:
y (
ArrayLike) – Data,(n, p);numpy.nanrows are missing.n_particles (
int) – Cloud size, at least 2.method (
str) –"bootstrap"or"auxiliary". The auxiliary variant needs the additive-Gaussian transition or atransitionmap to anchor its look-ahead.ess_threshold (
float) – Resample when the effective sample size falls below this fraction of the cloud (bootstrap only; the auxiliary filter resamples every step by construction).
- Return type:
_ParticleFilterResult- Returns:
The
_ParticleFilterResult.- Raises:
SpecificationError – If the method or bookkeeping is malformed.
NumericalError – If every particle’s weight underflows – the cloud has degenerated and the estimate is meaningless.