Module Ppl.Primitive

Module defining a type for primitive distributions

type 'a support =
| DiscreteFinite of 'a list

A list of valid values

| DiscreteInfinite

discrete dist with infinite support e.g. poisson

| ContinuousFinite of ('a * 'a) list

set of endpoints

| ContinuousInfinite

continuous dist with an infinite support e.g.

| Merged of 'a support * 'a support

combination of any of the above

The type of supports - the values with a distribution can take

module type PRIM_DIST = sig ... end

The signature for new primitive distributions

type 'a t

Type of primitive dists wrapping a module

New Distributions

val create_primitive : sample:(unit -> 'a) -> pdf:('a -> float) -> cdf:('a -> float) -> support:'a support -> ppf:('a -> float) -> 'a t

Predefined Distributions

val binomial : int -> float -> int t
val categorical : ('a * float) list -> 'a t
val normal : float -> float -> float t
val discrete_uniform : 'a list -> 'a t
val beta : float -> float -> float t
val gamma : float -> float -> float t
val poisson : float -> int t
val continuous_uniform : float -> float -> float t

Basic Operations

val pdf : 'a t -> 'a -> float
val logpdf : 'a t -> 'a -> float
val cdf : 'a t -> 'a -> float
val ppf : 'a t -> 'a -> float
val sample : 'a t -> 'a
val support : 'a t -> 'a support

Other

val merge_supports : ('a support * 'a support) -> 'a support