packages feed

welford-online-mean-variance 0.1.0.1 → 0.1.0.2

raw patch · 5 files changed

+10/−35 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Lib: someFunc :: IO ()
+ Statistics.Sample.WelfordOnlineMeanVariance: addValues :: (WelfordOnline a, Foldable f) => WelfordExistingAggregate a -> f a -> WelfordExistingAggregate a
+ Statistics.Sample.WelfordOnlineMeanVariance: isWelfordExistingAggregateEmpty :: WelfordExistingAggregate a -> Bool

Files

README.md view
@@ -8,7 +8,7 @@       let n = fromIntegral (length vals)       mean = VB.sum vals / n       var = VB.sum (VB.map (\x -> (x - mean) ^ 2) vals) / (n - 1)-      (wMean, _, wVarSample) = finalize $ foldl' addValue (WelfordExistingAggregateEmpty) (VB.toList vals)+      (wMean, _, wVarSample) = finalize $ foldl' addValue WelfordExistingAggregateEmpty (VB.toList vals)       print (mean, var)       print (wMean, wVarSample) 
− src/Lib.hs
@@ -1,6 +0,0 @@-module Lib-    ( someFunc-    ) where--someFunc :: IO ()-someFunc = putStrLn "someFunc"
src/Statistics/Sample/WelfordOnlineMeanVariance.hs view
@@ -5,9 +5,11 @@   ( WelfordExistingAggregate(..)   , WelfordOnline (..)   , addValue+  , addValues   , finalize   , nextValue   , newWelfordAggregate+  , isWelfordExistingAggregateEmpty   , Mean   , Variance   , SampleVariance@@ -35,6 +37,9 @@       }   deriving (Eq, Show, Read, Generic, NFData, Serialize) +isWelfordExistingAggregateEmpty :: WelfordExistingAggregate a -> Bool+isWelfordExistingAggregateEmpty WelfordExistingAggregateEmpty = True+isWelfordExistingAggregateEmpty _                             = False  -- | Create a new empty Aggreate for the calculation. newWelfordAggregate :: WelfordExistingAggregate a@@ -130,6 +135,9 @@       m2' = delta' `multiply` delta2'    in WelfordExistingAggregate count' mean' m2' +-- | Add multiple values to the current aggregate. This is `foldl addValue`.+addValues :: (WelfordOnline a, Foldable f) => WelfordExistingAggregate a -> f a -> WelfordExistingAggregate a+addValues = foldl addValue  -- | Calculate mean, variance and sample variance from aggregate. finalize :: (WelfordOnline a) => WelfordExistingAggregate a -> (Mean a, Variance a, SampleVariance a)@@ -143,26 +151,3 @@ nextValue agg val =   let agg' = addValue agg val    in (agg', finalize agg')----- # For a new value newValue, compute the new count, new mean, the new M2.--- # mean accumulates the mean of the entire dataset--- # M2 aggregates the squared distance from the mean--- # count aggregates the number of samples seen so far--- def update(existingAggregate, newValue):---     (count, mean, M2) = existingAggregate---     count' += 1---     delta = newValue - mean---     mean' += delta / count'---     delta2 = newValue - mean'---     M2' += delta * delta2---     return (count', mean', M2')---- # Retrieve the mean, variance and sample variance from an aggregate--- def finalize(existingAggregate):---     (count, mean, M2) = existingAggregate---     if count < 2:---         return float("nan")---     else:---         (mean, variance, sampleVariance) = (mean, M2 / count, M2 / (count - 1))---         return (mean, variance, sampleVariance)
test/Statistics/Sample/WelfordOnlineTest.hs view
@@ -7,9 +7,6 @@  import           Statistics.Sample.WelfordOnlineMeanVariance -main :: IO ()-main = putStrLn "Test suite not yet implemented"-  -- | Recursively generate candles generateNValues :: Int -> Gen [Double]
welford-online-mean-variance.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           welford-online-mean-variance-version:        0.1.0.1+version:        0.1.0.2 synopsis:       Online computation of mean and variance using the Welford algorithm. description:    Please see the README on GitHub at <https://github.com/githubuser/welford-online-mean-variance#readme> category:       Statistics@@ -27,7 +27,6 @@  library   exposed-modules:-      Lib       Statistics.Sample.WelfordOnlineMeanVariance   other-modules:       Paths_welford_online_mean_variance