# @vascosantos/moving-average

> Exponential Moving Average

Latest version **1.1.0** (published 2021-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vascosantos/moving-average
pnpm add @vascosantos/moving-average
yarn add @vascosantos/moving-average
bun add @vascosantos/moving-average
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-04-30 |
| First published | 2021-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 62 |
| Author | Pedro Teixeira |
| Maintainers | vascosantos |
| Keywords | moving, average, average, statistics |

## Links

- npm: https://www.npmjs.com/package/@vascosantos/moving-average
- Repository: https://github.com/pgte/moving-average
- Homepage: https://github.com/pgte/moving-average#readme
- Issues: https://github.com/pgte/moving-average/issues
- npm.io page: https://npm.io/package/@vascosantos/moving-average

## Recent versions

- 1.1.0 (latest) — 2021-04-30

## README

# moving-average

[![Build Status](https://travis-ci.org/pgte/moving-average.svg?branch=master)](https://travis-ci.org/pgte/moving-average)

Online calculation of Exponential Moving Average for Node.js.

Also suports Moving Variance, Moving Deviation and Forecast.

The [following](https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average) online algorithm is implemented:

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

## Install

```bash
$ npm install moving-average
```

## Use

```javascript
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

---
_Source: https://npm.io/package/@vascosantos/moving-average · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
