# statistics

> calculate mean standard deviation in one pass

Latest version **3.3.0** (published 2016-10-09) · 0 weekly downloads

## Install

```sh
npm install statistics
pnpm add statistics
yarn add statistics
bun add statistics
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.0 |
| Published | 2016-10-09 |
| First published | 2011-08-03 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Dominic Tarr |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/statistics
- Repository: https://github.com/dominictarr/statistics
- Homepage: http://github.com/dominictarr/statistics
- Issues: https://github.com/dominictarr/statistics/issues
- npm.io page: https://npm.io/package/statistics

## Recent versions

- 3.3.0 (latest) — 2016-10-09
- 3.2.0 — 2016-10-09
- 3.1.0 — 2016-10-09
- 3.0.0 — 2016-10-08
- 2.0.1 — 2016-01-03
- 2.0.0 — 2015-11-16
- 1.0.0 — 2011-08-03

## README

# statistics

a reduce function that calculates mean and standard deviation in one pass


I first wrote this module a long long time ago, and i used an object oriented
api. Today I needed to serialize a stats output to JSON, and then later parse it,
and keep using it. Continuing to use an OO api would mean a bunch of glue code,
so I rewrote it as a reduce function.

## example

``` js
var stats = require('statistics')

console.log([1,2,3].reduce(stats))
=> {
  mean: 2,
  stdev: 0.8164965809277263,
  count: 3,
  sum: 6,
  sqsum: 14
}
```
you probably only want to have the mean and stdev, the other fields are necessary for the reduce
function however.

## mutating reduce: require('statistics/mutate')

sometimes, a mutating reduce is prefured. this eases garbage collection,
and allows you to maintain a reference to an updating value.

otherwise the api is the same.

## functional is better than object oriented

statistics@2 and earlier used an object oriented api, but then I needed to serialize and parse a stats
object and keep using it. That was incredibly easy with a reduce function, but would have meant
a bunch of ugly glue code with OO.

## LICENSE

MIT

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