Library
Module
Module type
Parameter
Class
Class type
Sequential Monte-Carlo
include Intf.S
Core constructs of the DSL
sample dist
builds a computation that samples from dist
. Note that dist
must be a pure computation.
samplei dist
is similar to sample
except that dist
can be an impure computation (ie computing the distribution can involve sampling from other distributions).
map_score m f
behaves similarly to m
except that the associated computation will be reweighted according to the result of evaluating f
on the value of m
.
val map_log_score : 'a t -> ('a -> Log_space.t) -> 'a t
Same as map_score
excepts that a log-space likelihood is expected.
val score : float -> unit t
score s
reweights the computation by s
.
val log_score : Log_space.t -> unit t
log_score
behaves as score
except that a log-space weight is expected.
module List_ops : Intf.Foldable with type 'a t = 'a list and type 'a m := 'a t
module Array_ops :
Intf.Foldable with type 'a t = 'a array and type 'a m := 'a t
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 yield : unit t
yield
signals the scheduler that the particle is ready for resampling.
val log_score_noyield : Log_space.t -> unit t
log_score_noyield
behaves as log_score
but doesn't yield.
val map_log_score_noyield : 'a t -> ('a -> Log_space.t) -> 'a t
map_log_score_noyield
behaves as map_log_score
but doesn't yield.
map_score_noyield
behaves as map_score
but doesn't yield.
resampling
is used to improve the statistical quality of a population. See module Resampling
. By default, systematic_resampling
is a reasonable choice.
val systematic_resampling : resampling_strategy
val stratified_resampling : resampling_strategy
module Interruptible : sig ... end
The Interruptible
module exposes an implementation of Sequential Monte-Carlo that gives back the hand to the user after each resampling.
module Non_interruptible : sig ... end
The Non_interruptible
module exposes an implementation of Sequential Monte-Carlo that terminates when all particles terminate. Only use when the probabilistic program terminates almost surely!