moving-averages: This is a library for calculating moving averages on lists of numbers.

[ library, mathematics, mit ] [ Propose Tags ] [ Report a vulnerability ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.2.0.0
Dependencies base (>=4.7 && <5) [details]
License MIT
Copyright 2017
Author Josh Clayton
Maintainer sayhi@joshuaclayton.me
Category Mathematics
Home page https://github.com/joshuaclayton/moving-averages#readme
Source repo head: git clone https://github.com/joshuaclayton/moving-averages
Uploaded by joshuaclayton at 2017-05-12T22:45:05Z
Distributions NixOS:0.2.0.0
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1040 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-12 [all 1 reports]

Readme for moving-averages-0.2.0.0

[back to package description]

moving-averages

This is a library for calculating moving averages on lists of numbers.

Usage

import qualified Data.MovingAverage as MA

resultValues :: Floating a => MA.SmoothedResults a -> [a]
resultValues = map MA.srSmoothedValue . MA.srsResults

-- window of 2
resultValues <$> MA.simple 2 [5, 10, 20, 2]
-- Right [5.0, 7.5, 15.0, 11.0]

-- alpha of 0.5
resultValues <$> MA.singleExponential 0.5 [1, 2, 3, 4, 5]
-- Right [1, 1.5, 2.25, 3.125, 4.0625]

-- alpha of 0.5, beta of 0.1
resultValues <$> MA.doubleExponential 0.5 0.1 [3, 1, 4, 6, 8]
-- Right [3.0, 1.0, 1.5, 2.875, 4.71875]

License

Copyright 2017 Josh Clayton. See the LICENSE.