prbnmcn-stats
Library
Module
Module type
Parameter
Class
Class type
include Stats_intf.Fin_dist with type r = Q.t and type state = Random.State.t
type state = Random.State.t
type r = Q.t
type 'a prb = ( 'a, r ) Stats_intf.fin_prb
The type of finite probability measures with domain 'a
and range r
.
type 'a mes = ( 'a, r ) Stats_intf.fin_mes
The type of finite measures with domain 'a
and range r
.
Constructing r
-valued finitely supported functions.
val of_fun : int -> ( int -> r ) -> ( int, r ) Stats_intf.fin_fun
from_fun len f
constructs a finite function with support 0; ...; len-1
.
val of_array : r array -> ( int, r ) Stats_intf.fin_fun
from_array a
returns a finite function wrapping the array a
.
val of_assoc :
(module Hashtbl.S with type key = 'k) ->
('k * r) array ->
( 'k, r ) Stats_intf.fin_fun
from_assoc h a
returns a finite function constructed from the bindings in a
. The finite function is backed by a hash table whose implementation is given through the first class module h
. The behaviour of the function if elements in the support appear more than once is unspecified.
Constructing measures and probabilities
val measure : ( 'a, r ) Stats_intf.fin_fun -> 'a mes
Creates a finitely supported measure from a finite function. A measure is not necessarily normalized.
val probability : ( 'a, r ) Stats_intf.fin_fun -> 'a prb
Creates a finitely supported probability from a finite function. A probability is normalized.
Forgetful map from the type of finite probabilities to the type of measures.
Computes the empirical measure of an array of elements. Each element present in the array is mapped to its count.
val uniform : 't array -> 't prb
Finitely supported uniform distribution.
Binomial distribution. binomial p n
returns the probability of having k
successes over n
experiments, according to a biased coin p
.
Using measures and probabilities
Integrates a function against a finitely supported measure.
Evaluates a finitely supported probability on argument. Returns 0 if the argument is out of the support.
Evaluates a finitely supported measure on argument. Returns 0 if the argument is out of the support.
Iterates the given function on the support of the probability.
Iterates the given function on the support of the measure.
val sample : 't mes -> ( state, 't ) Stats_intf.gen
Samples from a finitely supported distribution presented as an unnormalized measure. This is mostly useful when sampling only once or twice from a distribution: consider converting to a categorical sampler when sampling repeatedly. Complexity: O(n) with n
the cardinality of the support.
val mean_generic :
(module Basic_structures.Basic_intf.Module with type t = 't and type R.t = r) ->
't mes ->
't
Compute the mean of a finite measure supported on an Intf.Module
.
val quantile :
(module Basic_structures.Basic_intf.Ordered with type t = 'elt) ->
'elt mes ->
r ->
'elt
quantile ord mes p
computes the p
th quantile of mes
. The underlying data is totally ordered by ord
.
Returns the raw data underlying a finitely supported measure.
Returns the raw data underlying a finitely supported probability.
type 'a pp := Format.formatter -> 'a -> unit
Pretty print a measure, with elements sorted according to the order relation on the support.
Pretty print a measure, with elements sorted by increasing measure..
module Dist : sig ... end