From 418069551b528e3855d2a39a6375f70a88b36a2e Mon Sep 17 00:00:00 2001 From: atomiks Date: Wed, 13 Dec 2017 23:54:33 +1100 Subject: [PATCH] Update standard-deviation.md --- snippets/standard-deviation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/standard-deviation.md b/snippets/standard-deviation.md index b1dd0b9c6..3641cbe14 100644 --- a/snippets/standard-deviation.md +++ b/snippets/standard-deviation.md @@ -7,7 +7,7 @@ Since there are two types of standard deviation, population and sample, you can ```js const standardDeviation = (arr, usePopulation) => { - const mean = arr.reduce((acc, val) => acc + val, 0); + 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)), []) .reduce((acc, val) => acc + val, 0)