Socket
Socket
Sign inDemoInstall

moving-average

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

moving-average

Exponential Moving Average


Version published
Maintainers
1
Weekly downloads
2,797
decreased by-23.03%
Bundle size
375 bytes
Minified + gzipped

Weekly downloads

Readme

Source

moving-average

Build Status

Online calculation of Exponential Moving Average for Node.js.

Also suports Moving Variance, Moving Deviation and Forecast.

The following online algorithm is implemented:

diff := x - mean
incr := alpha * diff
mean := mean + incr
variance := (1 - alpha) * (variance + diff * incr)
forecast := mean + alpha * diff

Install

$ npm install moving-average

Use

var timeInterval = 5 * 60 * 1000; // 5 minutes

var MA = require('moving-average');
var ma = MA(timeInterval);

setInterval(function() {
  ma.push(Date.now(), Math.random() * 500);
  console.log('moving average now is', ma.movingAverage());
  console.log('moving variance now is', ma.variance());
  console.log('moving deviation now is', ma.deviation());
  console.log('forecast is', ma.forecast());
});

License

MIT

Keywords

FAQs

Last updated on 09 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc