package prbnmcn-stats

  1. Overview
  2. Docs

Module Stats.GenSource

Generative distributions.

include Stats_intf.Gen
Sourcetype parameters = {
  1. nsamples : int;
  2. state : Random.State.t;
}
include Stats_intf.Sampling_monad with type 'a res = parameters -> (module Basic_structures.Basic_intf.Std with type t = 'a) -> ('a, float) Stats_intf.fin_mes
Sourcetype 'a t = 'a Stats_intf.gen

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

Sourcetype 'a res = parameters -> (module Basic_structures.Basic_intf.Std with type t = 'a) -> ('a, float) Stats_intf.fin_mes

'a res is the outcome of running a computation 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 run : 'a t -> 'a res

Running a monadic computation

Sourcemodule Infix : sig ... end
Sourceval float : float -> float t

float bound samples uniformly in 0; bound

Sourceval int : int -> int t

int bound samples uniformly in 0; bound-1

Sourceval bool : bool t

bool samples a boolean uniformly

Sourceval uniform : 'a array -> 'a t

uniform elts samples an element of the elts array by sampling an index uniformly.

Sourceval bernouilli : float -> bool t

bernouilli alpha samples true with probability alpha.

Sourceval geometric : float -> int t

geometric p samples a nonnegative integer according to the geometric law of parameter p.

Sourceval subsample : n:int -> 'a t -> 'a t

subsample ~n gen samples one out of n samples from gen.

Sourceval of_empirical : 'a Stats_intf.emp -> 'a t

of_empirical emp samples from emp matching exactly the empirical frequencies.

Sourceval exponential : rate:float -> float t

Exponential distribution via inverse CDF.

Sourceval box_muller : mean:float -> std:float -> (float * float) t

Gaussian distribution via Box-Muller transform. Returns a pair of independent gaussian variates with prescribed mean and standard deviation.

Sourceval gaussian : mean:float -> std:float -> float t

Gaussian distribution (wrapper over box-muller transform).

Sourceval poisson : lambda:float -> int t

Poisson distribution via inverse transform. Consider using other methods for large lambda.

Sourceval range : Stats_intf.range -> float t

Samples uniformly in the given range.

Sourceval categorical : ('a * float) list -> 'a t

Categorical distribution. Total mass need not be one. Does not aggregate mass of equal elements.

  • raises Invalid_argument

    if some weights are negative or if the total mass is zero.

Sourceval of_fin_mes : ('a, float) Stats_intf.fin_mes -> 'a t

Constructs a sampler from a finite measure through categorical. NB: this is mostly useful for sampling repeatedly from the distribution.

Sourcemodule Rational : sig ... end