-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | online statistics
--   
--   transformation of statistics to online algorithms
@package online
@version 0.2.0

module Online.Quantiles

-- | a raw non-online tdigest fold
tDigest :: Fold Double (TDigest 25)

-- | non-online version
tDigestQuantiles :: [Double] -> Fold Double [Double]

-- | non-online version
tDigestHist :: Fold Double (Maybe (NonEmpty HistBin))
data OnlineTDigest
OnlineTDigest :: TDigest 25 -> Int -> Double -> OnlineTDigest
[td] :: OnlineTDigest -> TDigest 25
[tdN] :: OnlineTDigest -> Int
[tdRate] :: OnlineTDigest -> Double
emptyOnlineTDigest :: Double -> OnlineTDigest

-- | decaying quantiles based on the tdigest library
onlineQuantiles :: Double -> [Double] -> Fold Double [Double]
median :: Double -> Fold Double Double
onlineInsert' :: Double -> OnlineTDigest -> OnlineTDigest
onlineInsert :: Double -> OnlineTDigest -> OnlineTDigest
onlineCompress :: OnlineTDigest -> OnlineTDigest
onlineForceCompress :: OnlineTDigest -> OnlineTDigest
onlineDigitize :: Double -> [Double] -> Fold Double Int

-- | decaying histogram based on the tdigest library
onlineDigestHist :: Double -> Fold Double (Maybe (NonEmpty HistBin))
instance GHC.Show.Show Online.Quantiles.OnlineTDigest

module Online.Stats

-- | Most common statistics are averages.
data Averager a b

-- | online takes a function and turns it into a <a>Fold</a> where the step
--   is an incremental update of the (isomorphic) statistic.
online :: (Fractional b) => (a -> b) -> (b -> b) -> Fold a b

-- | average
av :: (Fractional a) => Fold a a

-- | moving average
ma :: (Fractional a) => a -> Fold a a

-- | absolute average
absma :: (Fractional a) => a -> Fold a a

-- | average square
sqma :: (Fractional a) => a -> Fold a a

-- | standard deviation
std :: (Floating a) => a -> Fold a a

-- | the covariance of a tuple given an underlying central tendency fold
cov :: (Floating a) => Fold a a -> Fold (a, a) a

-- | a generalised version of correlation of a tuple
corr :: (Floating a) => Fold a a -> Fold a a -> Fold (a, a) a

-- | correlation of a tuple, specialised to Guassian
corrGauss :: (Floating a) => a -> Fold (a, a) a

-- | the beta in a simple linear regression of a tuple given an underlying
--   central tendency fold
beta :: (Floating a) => Fold a a -> Fold (a, a) a

-- | the alpha of a tuple
alpha :: (Floating a) => Fold a a -> Fold (a, a) a

-- | 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.
--   
--   value<tt>t = e</tt>t + 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,
--   
--   <pre>
--   &gt;&gt;&gt; L.fold (autocorr 0 1)
--   </pre>
--   
--   would estimate the one-step autocorrelation relationship of the
--   previous value and the current value over the entire sample set.
autocorr :: (Floating a, RealFloat a) => Fold a a -> Fold (a, a) a -> Fold a a
instance (GHC.Base.Monoid a, GHC.Base.Monoid b) => GHC.Base.Monoid (Online.Stats.Averager a b)

module Online.StatsL1

-- | A rough Median. The average absolute value of the stat is used to
--   callibrate estimate drift towards the medium
data Medianer a b
Medianer :: a -> b -> a -> Medianer a b
[medAbsSum] :: Medianer a b -> a
[medCount] :: Medianer a b -> b
[medianEst] :: Medianer a b -> a

-- | onlineL1 takes a function and turns it into a <a>Fold</a> where the
--   step is an incremental update of an (isomorphic) median statistic.
onlineL1 :: (Ord b, Fractional b) => b -> b -> (a -> b) -> (b -> b) -> Fold a b

-- | onlineL1' takes a function and turns it into a <a>Fold</a> where the
--   step is an incremental update of an (isomorphic) median statistic.
onlineL1' :: (Ord b, Fractional b) => b -> b -> (a -> b) -> (b -> b) -> Fold a (b, b)

-- | averageL1
avL1 :: (Ord a, Fractional a) => a -> Fold a a

-- | moving median
maL1 :: (Ord a, Fractional a) => a -> a -> a -> Fold a a

-- | moving absolute deviation
absmaL1 :: (Ord a, Fractional a) => a -> a -> a -> Fold a a

-- | covariance of a tuple
covL1 :: (Ord a, Fractional a) => a -> a -> a -> Fold (a, a) a

-- | correlation of a tuple
corrL1 :: (Ord a, Floating a) => a -> a -> a -> Fold (a, a) a

-- | the beta in a simple linear regression of a tuple
betaL1 :: (Ord a, Floating a) => a -> a -> a -> Fold (a, a) a

-- | the alpha in a simple linear regression of <a>snd</a> on <a>fst</a>
alphaL1 :: (Ord a, Floating a) => a -> a -> a -> Fold (a, a) a
autocorrL1 :: (Floating a, RealFloat a) => a -> a -> a -> a -> Fold a a


-- | online library
module Online
