package prbnmcn-dagger

  1. Overview
  2. Docs
type 'a t
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val map : 'a t -> ('a -> 'b) -> 'b t
val map2 : 'a t -> 'b t -> ('a -> 'b -> 'c) -> 'c t
val map_array : 'a t array -> ('a array -> 'b) -> 'b t
val if_ : bool t -> (bool -> 'a t) -> 'a t
module Infix : sig ... end
type !'a0 dist = Random.State.t -> 'a
val sample : 'a dist -> 'a t
val map_score : 'a t -> ('a -> float) -> 'a t
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
type particle_output = float
type resampling_state = unit
val fork : int -> unit t

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

  • raises [Invalid_arg]

    if n < 1.

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.

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 = {
  1. terminated : ('a * float) array;
    (*

    The terminated particles. These carry their return value.

    *)
  2. active : (particle_output * float) array;
    (*

    The active particles. These carry the value given in argument to yield.

    *)
  3. total_mass : float;
    (*

    The total mass of the population (including terminated particles).

    *)
}

'a population is the type of a population.

exception Invalid_population
val run : ?nthreads:int -> (particle_output, float, resampling_state) Resampling.strategy -> resampling_state -> npart:int -> 'a t -> RNG.t -> 'a population Seq.t

run ~nthreads 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 optional argument nthreads corresponds to the number of threads to be used when performing inference. Defaults to 1 (no parallelism). Maximum recommended value is Domain.recommended_domain_count ().

The model is evaluated as follows:

  1. all particles in the population have initially the same score;
  2. each particle evolves until it terminates or until it calls yield o, at which point it is suspended;
  3. when all particles are either terminated or suspended, resampling is executed on all particles (including terminated ones), resulting in a freshened population;
  4. execution resumes in step 2.

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 : ?nthreads:int -> (particle_output, float, resampling_state) Resampling.strategy -> resampling_state -> npart:int -> (int -> 'a t) -> RNG.t -> 'a population 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.

OCaml

Innovation. Community. Security.