Stats.Gen
Generative distributions.
module Make
(RNG : Stats_intf.Stateful_PRNG) :
Stats_intf.Gen with type state = RNG.t
Implementation of generative distributions parameterized by stateful RNG implementation.
Instantiation of the Make
functor with Random
.State.
include Stats_intf.Gen with type state = Stdlib.Random.State.t
Follows the module type of a sampling-based monad
include Basic_structures.Basic_intf.Monad
with type 'a t = (state, 'a) Stats_intf.gen
and type 'a res = (state, 'a) Stats_intf.gen
type 'a t = (state, 'a) Stats_intf.gen
'a t
is the type of computations of type 'a
type 'a res = (state, 'a) Stats_intf.gen
'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
module Infix : sig ... end
val float : float -> float t
float bound
samples uniformly in 0; bound
val int : int -> int t
int bound
samples uniformly in 0; bound-1
val bool : bool t
bool
samples a boolean uniformly
val shuffle : 'a array -> 'a array t
shuffle a
samples a uniform permutation of a
. Uses Fisher-Yates shuffle algorithm.
val uniform : 'a array -> 'a t
uniform elts
samples an element of the elts
array by sampling an index uniformly.
val bernoulli : float -> bool t
bernoulli alpha
samples true
with probability alpha
.
val geometric : float -> int t
geometric p
samples a nonnegative integer according to the geometric law of parameter p
.
val of_empirical : 'a Stats_intf.emp -> 'a t
of_empirical emp
samples from emp
matching exactly the empirical frequencies.
val exponential : rate:float -> float t
Exponential distribution via inverse CDF.
val 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.
val gaussian : mean:float -> std:float -> float t
Gaussian distribution (wrapper over box-muller transform).
val poisson : lambda:float -> int t
Poisson distribution via inverse transform. Consider using other methods for large lambda
.
val range : Stats_intf.range -> float t
Samples uniformly in the given range
.
val gamma : shape:float -> scale:float -> float t
Gamma distribution.
val categorical : ('a * float) array -> 'a t
Categorical distribution. Total mass need not be one. Does not aggregate mass of equal elements.
val without_replacement : int -> 'a list -> ('a list * 'a list) t
without_replacement n l
samples a subset of size n
from l
without replacement.
module Rational : sig ... end