package prbnmcn-dagger

  1. Overview
  2. Docs

Incremental lightweight Metropolis-Hastings

include sig ... end
include Intf.S

Core constructs of the DSL

include Intf.Core
type 'a t

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

type 'a res

'a res is the outcome of running a computation of type 'a

val return : 'a -> 'a t

return x injects a value x as a computation

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

Monadic bind

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

Functorial map

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

Applicative structure

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

N-array applicative structure

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

val run : 'a t -> 'a res

Running a monadic computation

val sample : 'a Dist.t -> 'a t

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

val 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).

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

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.

val stream_samples : 'a t -> RNG.t -> 'a Seq.t

Samples from the posterior described by a computation. Note that calling stream_samples when building a model is incorrect.

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
module Seq_ops : Intf.Foldable with type 'a t = 'a Seq.t and type 'a m := 'a t

Extra constructs of the incremental backend

The incremental backend can perform inference on models featuring explicit sharing of sub-computations. In practice, this allows to construct complex graphical models without having to use the (costlier) bind of the core language.

type 'a shared

The type of a shared sub-expression.

val with_shared : 'a t -> ('a shared -> 'b t) -> 'b t

with_shared m f allows to access a shareable representation of the computation m in the scope defined by f.

val with_shared_list : 'a t list -> ('a shared list -> 'b t) -> 'b t

with_shared_list m f is equivalent to folding with_shared on a list of computations.

val with_shared_array : 'a t array -> ('a shared array -> 'b t) -> 'b t

with_shared_array m f is equivalent to folding with_shared on an array of computations.

val use : 'a shared -> 'a t

use shared reifies a shareable representation of a computation as a bona fide computation of the same type.

val to_dot : string -> 'a t -> unit

to_dot file model generates the graph of the model in graphviz format and saves it to file.

module Infix : sig ... end

Experimental features

module Make_shared (C : sig ... end) : sig ... end

Make_shared allows to construct with operators for any mappable type.

OCaml

Innovation. Community. Security.