Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ewma

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ewma

Exponentially Weighted Moving Average

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
156K
increased by9.32%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version Build Status

EWMA

An exponential weighted moving average for Node.js and the browser!

npm install -g ewma

Usage

Compute the exponential weighted moving average of a series of values. The time at which you insert the value into Ewma is used to compute a weight (recent points are weighted higher). The parameter for defining the convergence speed (like most decay process) is the half-life.

e.g. with a half-life of 10 unit, if you insert 100 at t=0 and 200 at t=10 the ewma will be equal to (200 - 100)/2 = 150 (half of the distance between the new and the old value).

var ewma = new EWMA(halfLifeMs, initialValue, clock)

  • halfLifeMs - {Number} parameter representing the speed of convergence
  • initialValue - {Number} initial value
  • clock - Optional {Number} clock object used to read time, must support Date.now() style method. Defaults to Date.

returns an object computing the ewma average

ewma.insert(x)

  • x - The next value, ewma will automatically compute the EWMA based on the clock difference between this value and the last time insert was called

ewma.reset(x)

  • x - Set the EWMA to exactly x.

ewma.value()

Returns the current EWMA value.

Examples

These are generated using a 500ms interval with a half life indicated in the key. For the source code, or to reproduce yourself, check the Example directory.

Contributions

Contributions welcome, please ensure make runs clean.

License

MIT

Keywords

FAQs

Package last updated on 08 Sep 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc