Update standard-deviation.md

This commit is contained in:
atomiks
2017-12-13 23:12:42 +11:00
committed by GitHub
parent ddd72538f1
commit eb817e71d2

View File

@ -7,7 +7,7 @@ NOTE: This is **population standard deviation**. Use `/ (arr.length - 1)` at the
calculate **sample standard deviation**. calculate **sample standard deviation**.
```js ```js
const standardDeviation = (arr, val) => const standardDeviation = arr =>
Math.sqrt( Math.sqrt(
arr.reduce((acc, val) => acc.concat(Math.pow(val - arr.reduce((acc, val) => acc + val, 0) / arr.length, 2)), []) arr.reduce((acc, val) => acc.concat(Math.pow(val - arr.reduce((acc, val) => acc + val, 0) / arr.length, 2)), [])
.reduce((acc, val) => acc + val, 0) .reduce((acc, val) => acc + val, 0)