Resampling Algorithms

Introduction

In order to restore numerical stability to the sequential Monte Carlo algorithm as the effective sample size is reduced, resampling is used to adaptively move particles so as to better represent the posterior distribution. QInfer allows for such algorithms to be specified in a modular way.

LiuWestResampler - Liu and West (2000) resampling algorithm

Class Reference

class qinfer.resamplers.LiuWestResampler(a=0.98, h=None, maxiter=1000, debug=False, postselect=True, zero_cov_comp=1e-10, kernel=<built-in method randn of mtrand.RandomState object>)[source]

Bases: object

Creates a resampler instance that applies the algorithm of [LW01] to redistribute the particles.

Parameters:
  • a (float) – Value of the parameter \(a\) of the [LW01] algorithm to use in resampling.
  • h (float) – Value of the parameter \(h\) to use, or None to use that corresponding to \(a\).
  • maxiter (int) – Maximum number of times to attempt to resample within the space of valid models before giving up.
  • debug (bool) – Because the resampler can generate large amounts of debug information, nothing is output to the logger, even at DEBUG level, unless this flag is True.
  • postselect (bool) – If True, ensures that models are valid by postselecting.
  • zero_cov_comp (float) – Amount of covariance to be added to every parameter during resampling in the case that the estimated covariance has zero norm.
  • kernel (callable) – Callable function kernel(*shape) that returns samples from a resampling distribution with mean 0 and variance 1.

Warning

The [LW01] algorithm preserves the first two moments of the distribution (in expectation over the random choices made by the resampler) if and only if \(a^2 + h^2 = 1\), as is set by the h=None keyword argument.

a

ClusteringResampler - Cluster-based recursive resampler

class qinfer.resamplers.ClusteringResampler(eps=0.5, secondary_resampler=None, min_particles=5, metric='euclidean', weighted=False, w_pow=0.5, quiet=True)[source]

Bases: object

Creates a resampler that breaks the particles into clusters, then applies a secondary resampling algorithm to each cluster independently.

Parameters:secondary_resampler – Resampling algorithm to be applied to each cluster. If None, defaults to LiuWestResampler().