simplemovingaverage
v1.1.2
Published
Simple moving average time series smoothing.
Downloads
16
Maintainers
Readme
simplemovingaverage.js
Simple moving average time series smoothing in JavaScript.
Install
$ npm install simplemovingaverage
Usage
Node.js
var SimpleMovingAverage = require("simplemovingaverage");
var sma = new SimpleMovingAverage();
var setTimeSeries = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6];
var intWindowSize = 2;
sma.get(setTimeSeries, intWindowSize);
// => [1.5,3.5,5.5,7.5,9.5,1.5,3.5,5.5]
Browser
(Add necessary <script>
tag reference to simplemovingaverage.js
)
// SimpleMovingAverage is autoloaded to window.SimpleMovingAverage
var sma = new SimpleMovingAverage();
var setTimeSeries = [1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6];
var intWindowSize = 2;
sma.get(setTimeSeries, intWindowSize);
// => [1.5,3.5,5.5,7.5,9.5,1.5,3.5,5.5]
Tests
Gulp + Karma + PhantomJS + Jasmine
$ gulp
License
MIT. By Josh Ause.