Module type Resampling.Particles

A Particles module exposes primitives available to resampling algorithms.

type p

p is the type of particles

type o

o is the type of particle outputs.

type r

r is the type of the scores associated to each particle

val iter : (p -> r -> unit) -> unit

iter allows to iterate on the current population of particles.

val fold : ('acc -> p -> r -> 'acc) -> 'acc -> 'acc

fold allows to fold on the current population of particles.

val get_output : p -> o option

get_output p is the output of the particle at the last yield point. Returns None if the particle has terminated. See the documentation for yield in Smc_inference.

val get_score : p -> r

get_score p is the unnormalized score of the particle.

val append : p -> r -> unit

append p r appends particle p with score r to the next population.

val total : unit -> r

total () is the total mass of the current population.

val size : unit -> int

size () is the cardinality of the current population.

val ess : unit -> r

ess () is the estimated sample size. Varies between 0 and the cardinality of the current population. Computed as \left(\sum_{i=1}^N w_i^2\right)^{-1}, where N is equal to size () and the w_i are the normalized scores of each particle.