monoid-statistics-1.1.1: Monoids for calculation of statistics of sample
Safe HaskellNone
LanguageHaskell2010

Data.Monoid.Statistics.Extra

Contents

Description

Monoids for calculating various statistics in constant space. This module contains algorithms that should be generally avoided unless there's specific reason to use them.

Synopsis

Mean

data WelfordMean Source #

Incremental calculation of mean. Note that this algorithm doesn't offer better numeric precision than plain summation. Its only advantage is protection against double overflow:

>>> calcMean $ reduceSample @MeanKBN (replicate 100 1e308) :: Maybe Double
Just NaN
>>> calcMean $ reduceSample @WelfordMean (replicate 100 1e308) :: Maybe Double
Just 1.0e308

Unless this feature is needed KBNSum should be used. Algorithm is due to Welford [Welford1962]

\[ s_n = s_{n-1} + \frac{x_n - s_{n-1}}{n} \]

Constructors

WelfordMean !Int !Double 

Instances

Instances details
Eq WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Data WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> WelfordMean -> c WelfordMean #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WelfordMean #

toConstr :: WelfordMean -> Constr #

dataTypeOf :: WelfordMean -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WelfordMean) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WelfordMean) #

gmapT :: (forall b. Data b => b -> b) -> WelfordMean -> WelfordMean #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WelfordMean -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WelfordMean -> r #

gmapQ :: (forall d. Data d => d -> u) -> WelfordMean -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> WelfordMean -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> WelfordMean -> m WelfordMean #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WelfordMean -> m WelfordMean #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WelfordMean -> m WelfordMean #

Show WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Generic WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Associated Types

type Rep WelfordMean :: Type -> Type #

Semigroup WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Monoid WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Unbox WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

CalcMean WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

CalcCount WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Vector Vector WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

MVector MVector WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Real a => StatMonoid WelfordMean a Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

type Rep WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

type Rep WelfordMean = D1 ('MetaData "WelfordMean" "Data.Monoid.Statistics.Extra" "monoid-statistics-1.1.1-Et52IJUUy4YDKplMeouIOs" 'False) (C1 ('MetaCons "WelfordMean" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)))
newtype Vector WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

newtype MVector s WelfordMean Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

data MeanKahan Source #

Incremental calculation of mean. Sum of elements is calculated using compensated Kahan summation. It's provided only for sake of completeness. KBNSum should be used instead.

Constructors

MeanKahan !Int !KahanSum 

Instances

Instances details
Eq MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Data MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MeanKahan -> c MeanKahan #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MeanKahan #

toConstr :: MeanKahan -> Constr #

dataTypeOf :: MeanKahan -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MeanKahan) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MeanKahan) #

gmapT :: (forall b. Data b => b -> b) -> MeanKahan -> MeanKahan #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MeanKahan -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MeanKahan -> r #

gmapQ :: (forall d. Data d => d -> u) -> MeanKahan -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MeanKahan -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MeanKahan -> m MeanKahan #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MeanKahan -> m MeanKahan #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MeanKahan -> m MeanKahan #

Show MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Generic MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Associated Types

type Rep MeanKahan :: Type -> Type #

Semigroup MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Monoid MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Unbox MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

CalcMean MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

CalcCount MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Vector Vector MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

MVector MVector MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Real a => StatMonoid MeanKahan a Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

type Rep MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

type Rep MeanKahan = D1 ('MetaData "MeanKahan" "Data.Monoid.Statistics.Extra" "monoid-statistics-1.1.1-Et52IJUUy4YDKplMeouIOs" 'False) (C1 ('MetaCons "MeanKahan" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 KahanSum)))
newtype Vector MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

newtype MVector s MeanKahan Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

data MeanKB2 Source #

Incremental calculation of mean which uses second-order compensated Kahan-Babuška summation. In most cases KBNSum should provide enough precision.

Constructors

MeanKB2 !Int !KB2Sum 

Instances

Instances details
Eq MeanKB2 Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Methods

(==) :: MeanKB2 -> MeanKB2 -> Bool #

(/=) :: MeanKB2 -> MeanKB2 -> Bool #

Show MeanKB2 Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Semigroup MeanKB2 Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Monoid MeanKB2 Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

CalcMean MeanKB2 Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra

Real a => StatMonoid MeanKB2 a Source # 
Instance details

Defined in Data.Monoid.Statistics.Extra