6.14. pypfilt.resample¶
-
pypfilt.resample.
resample
(ctx, px)¶ Resample a particle population.
Parameters: - ctx – The simulation context.
- px – An array of particle state vectors.
The supported resampling methods are:
'basic'
: uniform random numbers from [0, 1].'stratified'
: uniform random numbers from [j / m, (j + 1) / m).'deterministic'
: select (j - a) / m for some fixed a.
Where m is the number of particles and j = 0, …, m - 1.
These algorithms are described in G Kitagawa, J Comp Graph Stat 5(1):1-25, 1996. doi:10.2307/1390750
-
pypfilt.resample.
resample_weights
(weights, rnd, method='deterministic')¶ Resample a particle weight array.
Parameters: - weights (np.ndarray) – The particle weights.
- rnd – A random number generator.
- method – The resampling method:
'basic'
,'stratified'
, or'deterministic'
(default).
Returns: A
(sample_ixs, weight)
tuple, wheresample_ixs
are the indices of the resampled particles andweight
is the new weight for each particle (a single float).
-
pypfilt.resample.
post_regularise
(ctx, px, new_px)¶ Sample model parameter values from a continuous approximation of the optimal filter, assuming that it has a smooth density.
This is the post-regularised particle filter (post-RPF). For details, see chapter 12 of Doucet et al., Sequential Monte Carlo Methods in Practice, Springer, 2001. doi:10.1007/978-1-4757-3437-9_12
Parameters: - ctx – The simulation context.
- px – The particles, prior to resampling.
- new_px – The particles after resampling directly from the discrete
distribution (
px
). This matrix will be destructively updated with model parameter values samples from the regularisation kernel.