Smc_inference.Float_smc
val return : 'a -> 'a t
module Infix : sig ... end
val map_log_score : 'a t -> ('a -> Log_space.t) -> 'a t
val score : float -> unit t
val log_score : Log_space.t -> unit t
module List_ops : sig ... end
module Array_ops : sig ... end
module Seq_ops : sig ... end
val fork : int -> unit t
fork n
creates n-1
particles. fork 1
does not create any new particle.
val get_score : Log_space.t t
get_score
returns the score of the current particle.
val set_score : Log_space.t -> unit t
set_score
sets the score of the current particle. This drops the current score of the particle: use wisely.
val yield : particle_output -> resampling_state t
yield o
signals that the particle produced output o
and is ready for resampling. The output o
is associated to the score of that particle at yield
time (i.e. just before resampling) in the output of the SMC sampler (see type population
).
type !'a0 population = {
terminated : ('a * float) array;
The terminated particles. These carry their return value.
*)active : (particle_output * float) array;
total_mass : float;
The total mass of the population (including terminated particles).
*)}
'a population
is the type of a population.
val run :
(particle_output, float, resampling_state) Resampling.strategy ->
resampling_state ->
npart:int ->
'a t ->
RNG.t ->
'a population Stdlib.Seq.t
run resampling resampling_state ~npart model rng
returns a lazy sequence of populations. The initial population has size npart
. resampling
corresponds to the resampling strategy. resampling_state
is the initial resampling state.
The model is evaluated as follows:
yield o
, at which point it is suspended;resampling
is executed on all particles (including terminated ones), resulting in a freshened population;The output of the algorithm is a sequence of population
. Each population is composed of yielded particles, attached to some value of type particle_output
, and of terminated particles.
Very important note: the output sequence is ephemeral.
val run_custom :
(particle_output, float, resampling_state) Resampling.strategy ->
resampling_state ->
npart:int ->
(int -> 'a t) ->
RNG.t ->
'a population Stdlib.Seq.t
run_custom resampling resampling_state ~npart model rng
returns a lazy sequence of populations. See the documentation of run
for more details on the meaning of each argument.
The only difference with run
is that run_custom
starts with a custom initial population, obtained by evaluating model
on the integers from 0
to npart-1
.