package prbnmcn-stats

  1. Overview
  2. Docs

float-valued finitely supported distributions.

include Stats_intf.Fin_dist with type r = float
type r = float
type 'a finfn = ('a, r) Stats_intf.fin_fun

The type of finite functions with domain 'a and range r.

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 measures and probabilities

val measure : (module Basic_structures.Basic_intf.Free_module_std with type Basis.t = 't and type R.t = r) -> ('t * r) list -> ('t, r) Stats_intf.fin_mes

Creates a finitely supported measure from weighted points. A measure is not necessarily normalized. The underlying set needs to be totally ordered.

val probability : (module Basic_structures.Basic_intf.Free_module_std with type Basis.t = 't and type R.t = r) -> ('t * r) list -> ('t, r) Stats_intf.fin_prb

Creates a finitely supported _probability_ from weighted points. A probability is normalized. The underlying set needs to be totally ordered.

  • raises Invalid_argument

    if the sum of the weights is not equal to one or if a weight is negative.

val kernel : ?h:(module Basic_structures.Basic_intf.Std with type t = 'a) -> (module Basic_structures.Basic_intf.Free_module_std with type Basis.t = 'b and type R.t = r) -> ('a -> ('b * r) list) -> ('a, 'b, r) Stats_intf.kernel

Creates a _kernel_. Needs not be normalized.

val compose : ?h:(module Basic_structures.Basic_intf.Std with type t = 'a) -> ('a, 'b, r) Stats_intf.kernel -> ('b, 'c, r) Stats_intf.kernel -> ('a, 'c, r) Stats_intf.kernel

Kernel composition.

val pushforward : ('t, r) Stats_intf.fin_mes -> ('t, 'u, r) Stats_intf.kernel -> ('u, r) Stats_intf.fin_mes

Computes the pushforward of a finitely supported measure along a kernel.

val inverse : ?h:(module Basic_structures.Basic_intf.Std with type t = 'u) -> ('t, r) Stats_intf.fin_prb -> ('t, 'u, r) Stats_intf.kernel -> ('u, r) Stats_intf.fin_prb * ('u, 't, r) Stats_intf.kernel

Bayesian inverse of a kernel. Defined up to a null set wrt the pushforward of the prior. Assumes that the kernel is probability-valued.

val constant_kernel : ('b, r) Stats_intf.fin_prb -> ('a, 'b, r) Stats_intf.kernel

Constant kernel.

val normalize : ('t, r) Stats_intf.fin_mes -> ('t, r) Stats_intf.fin_prb

Normalize a measure to obtain a probability measure.

val counts_of_empirical : (module Basic_structures.Basic_intf.Free_module_std with type Basis.t = 't and type R.t = r) -> 't array -> ('t, r) Stats_intf.fin_mes

Computes the empirical measure of an array of elements. Each element present in the array is mapped to its count.

val uniform : (module Basic_structures.Basic_intf.Free_module_std with type Basis.t = 't and type R.t = r) -> 't array -> ('t, r) Stats_intf.fin_prb

Finitely supported uniform distribution.

val coin : bias:r -> (bool, r) Stats_intf.fin_prb

Biased coin. Raises an error if bias is not in 0,1.

val binomial : (bool, r) Stats_intf.fin_prb -> int -> (int, r) Stats_intf.fin_prb

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

val integrate : ('t, r) Stats_intf.fin_mes -> ('t -> r) -> r

Integrates a function against a finitely supported measure.

val eval_prb : ('t, r) Stats_intf.fin_prb -> 't -> r

Evaluates a finitely supported probability on argument. Returns 0 if the argument is out of the support.

val eval_mes : ('t, r) Stats_intf.fin_mes -> 't -> r

Evaluates a finitely supported measure on argument. Returns 0 if the argument is out of the support.

val eval_kernel : 'a -> ('a, 'b, r) Stats_intf.kernel -> ('b * r) list

Evaluate a kernel at a point, yielding a finitely supported measure.

val sample : ('a, r) Stats_intf.fin_mes -> 'a 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 total_mass : ('t, r) Stats_intf.fin_mes -> r

Returns the total mass associated to a finitely supported measure.

val mean_generic : (module Basic_structures.Basic_intf.Module with type t = 'elt and type R.t = r) -> ('elt, r) Stats_intf.fin_mes -> 'elt

Compute the mean of a finite measure supported on an Intf.Module.

val mean : (r, r) Stats_intf.fin_mes -> r

Compute the mean of a finite measure supported by r.

val variance : (r, r) Stats_intf.fin_mes -> r

Compute the variance of a finite measure supported by r.

val raw_data_measure : ('t, r) Stats_intf.fin_mes -> [> `Measure of ('t * r) list ]

Returns the raw data underlying a finitely supported measure.

val raw_data_probability : ('t, r) Stats_intf.fin_prb -> [> `Probability of ('t * r) list ]

Returns the raw data underlying a finitely supported probability.

val pp_fin_mes : Format.formatter -> ('a, r) Stats_intf.fin_mes -> unit

Pretty print a measure, with elements sorted according to the order relation on the support.

val pp_fin_mes_by_measure : Format.formatter -> ('a, r) Stats_intf.fin_mes -> unit

Pretty print a measure, with elements sorted by increasing measure..

val fold_union : ('t -> r -> r -> 'a -> 'a) -> 't mes -> 't mes -> 'a -> 'a

Fold over the union of the supports of the given measures.

module Dist : sig ... end

Distances and divergences between measures.

OCaml

Innovation. Community. Security.