Safe Haskell | Safe-Inferred |
---|
A pure moving average module. The interface is agnostic to the scale of time that the average is tracking. It is up to the specific moving average module to handle that functionality.
- data MovingAverage = forall s . MovingAverage {
- movingAverageClear :: !(s -> s)
- movingAverageUpdate :: !(Double -> s -> s)
- movingAverageTick :: !(s -> s)
- movingAverageRate :: !(s -> Double)
- movingAverageState :: !s
- clear :: MovingAverage -> MovingAverage
- rate :: MovingAverage -> Double
- tick :: MovingAverage -> MovingAverage
- update :: Double -> MovingAverage -> MovingAverage
Documentation
data MovingAverage Source
This type encapsulates the interface of the different moving average implementations in such a way that they can be reused without plumbing the types through the other components that use moving averages. Most people won't ever need to use record fields of this type.
forall s . MovingAverage | |
|
clear :: MovingAverage -> MovingAverageSource
Reset a moving average back to a starting state.
rate :: MovingAverage -> DoubleSource
Get the current rate of the moving average.
tick :: MovingAverage -> MovingAverageSource
Update the average based upon an interval specified by the moving average implementation.
update :: Double -> MovingAverage -> MovingAverageSource
Update the average with the specified value.