monoid-statistics-0.2: Monoids for calculation of statistics of sample

Data.Monoid.Statistics.Numeric

Synopsis

# Mean and variance

newtype Count a Source

Simplest statistics. Number of elements in the sample

Constructors

 Count FieldscalcCountI :: a

Instances

 Show a => Show (Count a) Integral a => Monoid (Count a) CalcCount (Count Int) Integral a => StatMonoid (Count a) b

asCount :: Count a -> Count aSource

Fix type of monoid

data Mean Source

Mean of sample. Samples of Double,Float and bui;t-in integral types are supported

Numeric stability of `mappend` is not proven.

Constructors

 Mean !Int !Double

Instances

 Show Mean Monoid Mean CalcMean Mean CalcCount Mean ConvertibleToDouble a => StatMonoid Mean a

Fix type of monoid

data Variance Source

Intermediate quantities to calculate the standard deviation.

Constructors

 Variance !Int !Double !Double

Instances

 Show Variance Monoid Variance Using parallel algorithm from: Chan, Tony F.; Golub, Gene H.; LeVeque, Randall J. (1979), Updating Formulae and a Pairwise Algorithm for Computing Sample Variances., Technical Report STAN-CS-79-773, Department of Computer Science, Stanford University. Page 4. CalcVariance Variance CalcMean Variance CalcCount Variance ConvertibleToDouble a => StatMonoid Variance a

Fix type of monoid

class CalcCount m whereSource

Methods

calcCount :: m -> IntSource

Number of elements in sample

Instances

 CalcCount Variance CalcCount Mean CalcCount (Count Int)

class CalcMean m whereSource

Methods

calcMean :: m -> DoubleSource

Calculate esimate of mean of a sample

Instances

 CalcMean Variance CalcMean Mean

class CalcVariance m whereSource

Methods

calcVariance :: m -> DoubleSource

Calculate biased estimate of variance

Calculate unbiased estimate of the variance, where the denominator is \$n-1\$.

Instances

 CalcVariance Variance

calcStddev :: CalcVariance m => m -> DoubleSource

Calculate sample standard deviation (biased estimator, \$s\$, where the denominator is \$n-1\$).

calcStddevUnbiased :: CalcVariance m => m -> DoubleSource

Calculate standard deviation of the sample (unbiased estimator, \$sigma\$, where the denominator is \$n\$).

# Maximum and minimum

newtype Max Source

Calculate maximum of sample. For empty sample returns NaN. Any NaN encountedred will be ignored.

Constructors

 Max FieldscalcMax :: Double

Instances

 Show Max Monoid Max StatMonoid Max Double

newtype Min Source

Calculate minimum of sample. For empty sample returns NaN. Any NaN encountedred will be ignored.

Constructors

 Min FieldscalcMin :: Double

Instances

 Show Min Monoid Min StatMonoid Min Double

# Conversion to Double

class ConvertibleToDouble a whereSource

Data type which could be convered to Double

Methods

toDouble :: a -> DoubleSource