online-0.2.0: online statistics

Safe HaskellSafe
LanguageHaskell2010

Online.Stats

Contents

Synopsis

convert a statistic to online

data Averager a b Source #

Most common statistics are averages.

Instances

(Monoid a, Monoid b) => Monoid (Averager a b) Source # 

Methods

mempty :: Averager a b #

mappend :: Averager a b -> Averager a b -> Averager a b #

mconcat :: [Averager a b] -> Averager a b #

online :: Fractional b => (a -> b) -> (b -> b) -> Fold a b Source #

online takes a function and turns it into a Fold where the step is an incremental update of the (isomorphic) statistic.

common statistics

av :: Fractional a => Fold a a Source #

average

online statistics

ma :: Fractional a => a -> Fold a a Source #

moving average

absma :: Fractional a => a -> Fold a a Source #

absolute average

sqma :: Fractional a => a -> Fold a a Source #

average square

std :: Floating a => a -> Fold a a Source #

standard deviation

cov :: Floating a => Fold a a -> Fold (a, a) a Source #

the covariance of a tuple given an underlying central tendency fold

corr :: Floating a => Fold a a -> Fold a a -> Fold (a, a) a Source #

a generalised version of correlation of a tuple

corrGauss :: Floating a => a -> Fold (a, a) a Source #

correlation of a tuple, specialised to Guassian

beta :: Floating a => Fold a a -> Fold (a, a) a Source #

the beta in a simple linear regression of a tuple given an underlying central tendency fold

alpha :: Floating a => Fold a a -> Fold (a, a) a Source #

the alpha of a tuple

autocorr :: (Floating a, RealFloat a) => Fold a a -> Fold (a, a) a -> Fold a a Source #

autocorrelation is a slippery concept. This method starts with the concept that there is an underlying random error process (e), and autocorrelation is a process on top of that ie for a one-step correlation relationship.

valuet = et + k * e@t-1

where k is the autocorrelation.

There are thus two online rates needed: one for the average being considered to be the dependent variable, and one for the online of the correlation calculation between the most recent value and the moving average. For example,

>>> L.fold (autocorr 0 1)

would estimate the one-step autocorrelation relationship of the previous value and the current value over the entire sample set.