Travis build: 391

This commit is contained in:
Travis CI
2017-12-28 08:30:19 +00:00
parent 294a22ea5e
commit 203edf9ba2
141 changed files with 1389 additions and 1044 deletions

View File

@ -10,13 +10,15 @@ You can omit the second argument to get the sample standard deviation or set it
const standardDeviation = (arr, usePopulation = false) => {
const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;
return Math.sqrt(
arr.reduce((acc, val) => acc.concat(Math.pow(val - mean, 2)), [])
.reduce((acc, val) => acc + val, 0) / (arr.length - (usePopulation ? 0 : 1))
arr
.reduce((acc, val) => acc.concat(Math.pow(val - mean, 2)), [])
.reduce((acc, val) => acc + val, 0) /
(arr.length - (usePopulation ? 0 : 1))
);
};
```
```js
standardDeviation([10,2,38,23,38,23,21]) // 13.284434142114991 (sample)
standardDeviation([10,2,38,23,38,23,21], true) // 12.29899614287479 (population)
standardDeviation([10, 2, 38, 23, 38, 23, 21]); // 13.284434142114991 (sample)
standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (population)
```