Module Stats

module Stats: sig .. end
Statistics module

The module includes some basic statistical functions such as mean, variance, skew, and etc. It also includes the following three submodules.

The Stats.Rnd module provides random number generators of various distributions.

The Stats.Pdf module provides a range of probability density/mass functions of different distributions.

The Stats.Cdf module provides cumulative distribution functions.

Please refer to GSL documentation for details.



Randomisation functions

val seed : int -> unit
seed x sets x as seed for the internal random number generator.
val shuffle : 'a array -> 'a array
shuffle x return a new array of the shuffled x.
val choose : 'a array -> int -> 'a array
choose x n draw n samples from x without replecement.
val sample : 'a array -> int -> 'a array
sample x n draw n samples from x with replacement.

Basic statistical functions

val mean : ?w:float array -> float array -> float
val variance : ?w:float array -> ?mean:float -> float array -> float
val std : ?w:float array -> ?mean:float -> float array -> float
val absdev : ?w:float array -> ?mean:float -> float array -> float
val skew : ?w:float array -> ?mean:float -> ?sd:float -> float array -> float
val kurtosis : ?w:float array -> ?mean:float -> ?sd:float -> float array -> float
val central_moment : int -> float array -> float
val covariance : ?mean0:float -> ?mean1:float -> float array -> float array -> float
val correlation : float array -> float array -> float
val pearson_r : float array -> float array -> float
val kendall_tau : float array -> float array -> float
val spearman_rho : float array -> float array -> float
val autocorrelation : ?lag:int -> float array -> float
val min : float array -> float
val max : float array -> float
val minmax : float array -> float * float
val min_i : float array -> float * int
val max_i : float array -> float * int
val minmax_i : float array -> float * int * float * int
val sort : ?inc:bool -> float array -> float array
val rank : float array -> float array
rank x translates each element in x to its ranking. The ranking Order is from the smallest one to the largest. E.g., rank [|54.; 74.; 55.; 86.; 56.|] returns [|1.; 4.; 2.; 5.; 3.|]. Note that the ranking starts with one!

MCMC: Markov Chain Monte Carlo

val metropolis_hastings : (float array -> float) -> float array -> int -> float array array
TODO: metropolis_hastings f p n is Metropolis-Hastings MCMC algorithm. f is pdf of the p
val gibbs_sampling : (float array -> int -> float) -> float array -> int -> float array array
TODO: gibbs_sampling f p n is Gibbs sampler. f is a sampler based on the full conditional function of all variables

Random numbers, PDF, and CDF

module Rnd: sig .. end
module Pdf: sig .. end
module Cdf: sig .. end