Update standard-deviation.md
This commit is contained in:
@ -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))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user