package prbnmcn-dagger

  1. Overview
  2. Docs

Module Dagger.Smc_inferenceSource

Sequential Monte-Carlo

include Intf.S

Core constructs of the DSL

include Intf.Core
Sourcetype 'a t

'a t is the type of computations of type 'a

Sourceval return : 'a -> 'a t

return x injects a value x as a computation

Sourceval bind : 'a t -> ('a -> 'b t) -> 'b t

Monadic bind

Sourceval map : 'a t -> ('a -> 'b) -> 'b t

Functorial map

Sourceval map2 : 'a t -> 'b t -> ('a -> 'b -> 'c) -> 'c t

Applicative structure

Sourceval map_array : 'a t array -> ('a array -> 'b) -> 'b t

N-ary applicative structure

Sourceval if_ : bool t -> (bool -> 'a t) -> 'a t

If-then-else, mostly useful for monads featuring incremental computation. Allows to efficiently bind on a boolean computation.

Sourcemodule Infix : Intf.Infix with type 'a t := 'a t
Sourceval sample : 'a Dist.t -> 'a t

sample dist builds a computation that samples from dist. Note that dist must be a pure computation.

Sourceval samplei : 'a Dist.t t -> 'a t

samplei dist is similar to sample except that dist can be an impure computation (ie computing the distribution can involve sampling from other distributions).

Sourceval map_score : 'a t -> ('a -> float) -> 'a t

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.

Sourceval map_log_score : 'a t -> ('a -> Log_space.t) -> 'a t

Same as map_score excepts that a log-space likelihood is expected.

Sourceval score : float -> unit t

score s reweights the computation by s.

  • raises Invalid_arg

    if s < 0

Sourceval log_score : Log_space.t -> unit t

log_score behaves as score except that a log-space weight is expected.

Sourcemodule List_ops : Intf.Foldable with type 'a t = 'a list and type 'a m := 'a t
Sourcemodule Array_ops : Intf.Foldable with type 'a t = 'a array and type 'a m := 'a t
Sourcemodule Seq_ops : Intf.Foldable with type 'a t = 'a Seq.t and type 'a m := 'a t
Sourceval fork : int -> unit t

fork n creates n-1 particles. fork 1 does not create any new particle.

  • raises [Invalid_arg]

    if n < 1.

Sourceval get_score : Log_space.t t

get_score returns the score of the current particle.

Sourceval yield : unit t

yield signals the scheduler that the particle is ready for resampling.

Sourceval log_score_noyield : Log_space.t -> unit t

log_score_noyield behaves as log_score but doesn't yield.

Sourceval score_noyield : float -> unit t

score_noyield behaves as score but doesn't yield.

Sourceval 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.

Sourceval map_score_noyield : 'a t -> ('a -> float) -> 'a t

map_score_noyield behaves as map_score but doesn't yield.

Sourcetype resampling_strategy

resampling is used to improve the statistical quality of a population. See module Resampling. By default, systematic_resampling is a reasonable choice.

Sourceval systematic_resampling : resampling_strategy
Sourceval stratified_resampling : resampling_strategy
Sourceexception Invalid_population
Sourcemodule Interruptible : sig ... end

The Interruptible module exposes an implementation of Sequential Monte-Carlo that gives back the hand to the user after each resampling.

Sourcemodule 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!