1.0.4 • Published 7 years ago

optimal-std-dev v1.0.4

Weekly downloads
49
License
ISC
Repository
-
Last release
7 years ago

Optimal Standard Deviation Calculation

Calculates the mean, standard deviation, and variance of an array in one loop. This is based on Mark Hoemmen's work, Computing the standard deviation efficiently published August 25, 2007.

Usage

Install:

npm install --save optimal-std-dev

Import:

var calcStdDev = require('optimal-std-dev');

Use with a normal array:

var calcValues = calcStdDev([1, 2, 3, 10]);

Use with an accessor provided as a string:

var calcValues = calcStdDev([{ n: 1 }, { n: 2 }], 'n');

Use with an accessor provided as a function:

var calcValues = calcStdDev([{ n: 1 }, { n: 2 }], function (n) { return n + 1; });

Returns an object with the following properties:

{
  sum: 16,
  mean: 4,
  popStdDev: 3.5355339059327378,
  popVariance: 12.5,
  sampleStdDev: 4.08248290463863,
  sampleVariance: 16.666666666666668
}

The Calculation

screen shot 2017-02-14 at 10 40 37 am

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago