Abstract

Statistics functions parameterised over the concrete representation of reals.

Synopsis

module type statistics = {
type t
val mean [n]: [n]t -> t
val gmean [n]: [n]t -> t
val hmean [n]: [n]t -> t
val qmean [n]: [n]t -> t
val variance [n]: [n]t -> t
val stddev [n]: [n]t -> t
val covariance [n]: [n]t -> [n]t -> t
val correlation [n]: [n]t -> [n]t -> t
val variance_pop [n]: [n]t -> t
val stddev_pop [n]: [n]t -> t
val skewness [n]: [n]t -> t
val skewness_adj [n]: [n]t -> t
val kurtosis [n]: [n]t -> t
val kurtosis_excess [n]: [n]t -> t
val median [n]: [n]t -> t
val median_sorted [n]: [n]t -> t
val quantile [n]: [n]t -> t -> t
val quantile_sorted [n]: [n]t -> t -> t
val mode [n]: [n]t -> t
val mode_sorted [n]: [n]t -> t
type regression_result = {beta: t, mu: t}
val regress [n]: [n]t -> [n]t -> regression_result
val erf: t -> t
val gamma: t -> t
val gammaln: t -> t
type^ dist 'a
val mk_poison: {lambda: t} -> dist i32
val mk_normal: {mu: t, sigma: t} -> dist t
val mk_uniform: {a: t, b: t} -> dist t
val pmf: dist i32 -> i32 -> t
val pdf: dist t -> t -> t
val cdf 'a: dist a -> a -> t
val sample 'a: dist a -> t -> a
}
module mk_statistics: (R: float) -> statistics with t = R.t

Description

module type statistics
type t

The type of scalars that the functions operate on.

val mean [n]: [n]t -> t

mean vs returns the arithmetic mean of the values contained in vs.

val gmean [n]: [n]t -> t

gmean vs returns the geometric mean of the values contained in vs.

val hmean [n]: [n]t -> t

hmean vs returns the harmonic mean of the values contained in vs.

val qmean [n]: [n]t -> t

qmean vs returns the quadratic mean of the values contained in vs. Also known as "root mean square".

val variance [n]: [n]t -> t

variance vs returns the sample variance of the values contained in vs. The sample variance is the square of the sample standard deviation.

val stddev [n]: [n]t -> t

stddev vs returns the sample standard deviation of the values contained in vs. The sample standard deviation is the square root of the sample variance.

val covariance [n]: [n]t -> [n]t -> t

covariance xs ys returns the sample covariance between the values contained in xs and ys.

val correlation [n]: [n]t -> [n]t -> t

correlation xs ys returns the sample (Pearson) correlation between the values contained in xs and ys.

val variance_pop [n]: [n]t -> t

variance_pop vs returns the population variance of the values contained in vs. The population variance is the square of the population standard deviation.

val stddev_pop [n]: [n]t -> t

stddev_pop vs returns the population standard deviation of the values contained in vs. The population standard deviation is the square root of the population variance.

val skewness [n]: [n]t -> t

skewness vs returns the skewness of the values contained in vs. The skewness measures the assymetry of the values in vs. If the skewness is positive, the upper tail is thicker than the lower tail, whereas, if the skewness is negative, the lower tail is thicker than the upper tail. The skewness of a set of normally distributed values is zero.

val skewness_adj [n]: [n]t -> t

skewness_adj vs returns the adjusted Fisher-Pearson coefficient of skewness for the values contained in vs.

val kurtosis [n]: [n]t -> t

kurtosis vs returns the (non-excess) kurtosis of the values contained in vs.

val kurtosis_excess [n]: [n]t -> t

kurtosis_excess vs returns the excess kurtosis of the values contained in vs.

val median [n]: [n]t -> t

Median value of array.

val median_sorted [n]: [n]t -> t

Median value of sorted array.

val quantile [n]: [n]t -> t -> t

Quantile of array.

val quantile_sorted [n]: [n]t -> t -> t

Quantile of sorted array.

val mode [n]: [n]t -> t

The most frequently occuring element of an array.

val mode_sorted [n]: [n]t -> t

The most frequently occuring element of a sorted array.

type regression_result = {beta: t, mu: t}

beta is the slope and mu is the mean.

val regress [n]: [n]t -> [n]t -> regression_result

Linear regression in two variables.

val erf: t -> t

erf x returns a polynomial approximation to the Gauss error function applied to x. The maximal approximation error is 0.00000012 for any argument x.

val gamma: t -> t

gamma x returns the value (x-1)! for positive integer values x. Extended to work for positive non-integer values.

val gammaln: t -> t

gammaln x returns ln((x-1)!), extended to work with positive non-integer values. Notice that gammaln is numerically stable in contrast to calculating log(gamma x) with large xs.

type^ dist 'a

Generic type for distributions. Discrete distributions have type dist i32, whereas continuous distributions have type dist t.

val mk_poison: {lambda: t} -> dist i32
val mk_normal: {mu: t, sigma: t} -> dist t
val mk_uniform: {a: t, b: t} -> dist t
val pmf: dist i32 -> i32 -> t
val pdf: dist t -> t -> t
val cdf 'a: dist a -> a -> t
val sample 'a: dist a -> t -> a

sample d r returns a sample from the distribution d given a real value r taken from a uniform distribution U(0,1).