Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data WelfordExistingAggregate a
- class WelfordOnline a where
- newWelfordAggregateDef :: WelfordOnline a => a -> WelfordExistingAggregate a
- newWelfordAggregate :: WelfordExistingAggregate a
- welfordCount :: WelfordExistingAggregate a -> Int
- mWelfordMean :: WelfordExistingAggregate a -> Maybe a
- welfordMeanDef :: WelfordOnline a => a -> WelfordExistingAggregate a -> a
- addValue :: WelfordOnline a => WelfordExistingAggregate a -> a -> WelfordExistingAggregate a
- addValues :: (WelfordOnline a, Foldable f) => WelfordExistingAggregate a -> f a -> WelfordExistingAggregate a
- mFinalize :: WelfordOnline a => WelfordExistingAggregate a -> Maybe (Mean a, Variance a, SampleVariance a)
- finalize :: WelfordOnline a => WelfordExistingAggregate a -> (Mean a, Variance a, SampleVariance a)
- nextValue :: WelfordOnline a => WelfordExistingAggregate a -> a -> (WelfordExistingAggregate a, (Mean a, Variance a, SampleVariance a))
- isWelfordExistingAggregateEmpty :: WelfordExistingAggregate a -> Bool
- type Mean a = a
- type Variance a = a
- type SampleVariance a = a
Documentation
data WelfordExistingAggregate a Source #
For the storage of required information.
WelfordExistingAggregateEmpty | Emtpy aggregate. Needed as |
WelfordExistingAggregate | |
|
Instances
class WelfordOnline a where Source #
Class for all data strucutres that can be used to computer the Welford approximation. For instance, this can be used to compute the Welford algorithm on a Vector
s of Fractional
, while only
requiring to handle one WelfordExistingAggregate
.
Instances
WelfordOnline Rational Source # | |
WelfordOnline Double Source # | |
WelfordOnline Float Source # | |
WelfordOnline a => WelfordOnline (Vector a) Source # | |
(WelfordOnline a, Storable a) => WelfordOnline (Vector a) Source # | |
(WelfordOnline a, Unbox a) => WelfordOnline (Vector a) Source # | |
newWelfordAggregateDef :: WelfordOnline a => a -> WelfordExistingAggregate a Source #
Create a new empty Aggreate by specifying an example a
value. It is safe to use the `*Unsafe` record field selectors from `WelfordExistingAggregate a`, when creating the data structure using
this fuction.
newWelfordAggregate :: WelfordExistingAggregate a Source #
Create a new empty Aggreate for the calculation.
welfordCount :: WelfordExistingAggregate a -> Int Source #
Get counter safely, returns Nothing if WelfordExistingAggregateEmpty
.
mWelfordMean :: WelfordExistingAggregate a -> Maybe a Source #
Get counter safely, returns Nothing if WelfordExistingAggregateEmpty
.
welfordMeanDef :: WelfordOnline a => a -> WelfordExistingAggregate a -> a Source #
Get counter with specifying a default value.
addValue :: WelfordOnline a => WelfordExistingAggregate a -> a -> WelfordExistingAggregate a Source #
Add one value to the current aggregate.
addValues :: (WelfordOnline a, Foldable f) => WelfordExistingAggregate a -> f a -> WelfordExistingAggregate a Source #
Add multiple values to the current aggregate. This is `foldl addValue`.
mFinalize :: WelfordOnline a => WelfordExistingAggregate a -> Maybe (Mean a, Variance a, SampleVariance a) Source #
Calculate mean, variance and sample variance from aggregate. Safe function.
finalize :: WelfordOnline a => WelfordExistingAggregate a -> (Mean a, Variance a, SampleVariance a) Source #
Calculate mean, variance and sample variance from aggregate. Calls error
for WelfordExistingAggregateEmpty
.
nextValue :: WelfordOnline a => WelfordExistingAggregate a -> a -> (WelfordExistingAggregate a, (Mean a, Variance a, SampleVariance a)) Source #
Add a new sample to the aggregate and compute mean and variances.
isWelfordExistingAggregateEmpty :: WelfordExistingAggregate a -> Bool Source #
Check if it is aggregate is empty
type SampleVariance a = a Source #