The moving-averages package

[ Tags: library, mathematics, mit ] [ Propose Tags ]

[Skip to Readme]

Properties

Versions 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 Fri May 12 22:45:05 UTC 2017 by joshuaclayton
Distributions NixOS:0.2.0.0
Downloads 219 total (13 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-05-12 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


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.