Update standard-deviation.md

This commit is contained in:
atomiks
2017-12-13 23:55:08 +11:00
committed by GitHub
parent 418069551b
commit 98f56cbf23

View File

@ -9,7 +9,7 @@ Since there are two types of standard deviation, population and sample, you can
const standardDeviation = (arr, usePopulation) => {
const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length;
return Math.sqrt(
arr.reduce((acc, val) => acc.concat(Math.pow(val - mean / arr.length, 2)), [])
arr.reduce((acc, val) => acc.concat(Math.pow(val - mean, 2)), [])
.reduce((acc, val) => acc + val, 0)
/ (arr.length - (usePopulation ? 0 : 1))
);