Module Sample.Summary

module Summary: sig .. end
Calculates summary statistics over a possibly infinite stream of data.

The algorithm runs in O(1) space and O(n) time.

It is preferred for computing standard deviation, because roundoff errors in floating point operations might lead to taking a square root of a negative value.

References

  1. D. E. Knuth, "The Art of Computer Programming, Volume 2: Seminumerical Algorithms", 2nd edition, Section 4.2.2, p216.
  2. T. B. Terriberry, "Computing Higher-Order Moments Online", 2008, http://people.xiph.org/~tterribe/notes/homs.html


type t 
val empty : t
Empty data set.
val add : t -> float -> t
Adds a value to the data set.
val max : t -> float
Returns the maximum added value or nan if the data set is empty.
val min : t -> float
Returns the minimum added value or nan is the data set is empty.
val size : t -> int
Returns the number of available values.
val mean : t -> float
Returns the arithmetic mean of the values that have been added or nan if the data set is empty.
val variance : t -> float
Returns the variance of the available values or nan if the data set is empty.
val sd : t -> float
Returns the standard deviation of the values that have been added or nan if the data set is empty.
val skewness : t -> float
Returns the skewness of the values that have been added or nan if the data set is empty.

Note: for small sample sizes estimated value might be inaccurate, See issue #20.

val kurtosis : t -> float
Returns the excess kurtosis of the values that have been added or nan if the data set is empty.

Note: for small sample sizes estimated value might be inaccurate, See issue #20.

module Monoid: Algebra.Monoid.S  with type t := t