BSD-3-Clause licensed by Manuel Schneckenreither
Maintained by [email protected]
This version can be pinned in stack with:welford-online-mean-variance-0.2.0.0@sha256:989467b58d2fddae56e000533a2a9b9934cd696a7319ff632a4d154d1757b578,2069

Module documentation for 0.2.0.0

Welford: Online mean and variance computation

Example

example :: [Double] -> IO ()
example vals = do
  let n = fromIntegral (length vals)
      mean = sum vals / n
      var = sum (map (\x -> (x - mean) ^ 2) vals) / (n - 1)
      (wMean, _, wVarSample) = finalize $ foldl' addValue WelfordExistingAggregateEmpty vals
  print (mean, var)
  print (wMean, wVarSample)

WelfordExistingAggregate is used to save the state. Use the function finalize to retrieve the current estimates for the mean, variance and sample variance.

Changes

Changelog for welford

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to the Haskell Package Versioning Policy.

Unreleased

0.1.0.0 - YYYY-MM-DD