From b70c76afd3309d51d6fbd67bf2836f31f062a956 Mon Sep 17 00:00:00 2001 From: atomiks Date: Wed, 13 Dec 2017 23:55:08 +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 3641cbe14..442052761 100644 --- a/snippets/standard-deviation.md +++ b/snippets/standard-deviation.md @@ -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)) );