Last active
May 8, 2018 03:46
-
-
Save jonathanmarvens/d8421f3769f880aa4af3baf978a8e8fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mean = (values) => { | |
const sum = values.reduce((sum, value) => (sum + value), 0) | |
const valuesCount = values.length | |
return (sum / valuesCount) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const standardDeviation = (values) => { | |
const average = mean(values) | |
const squaredDifferences = values.map((value) => { | |
const difference = (value - average) | |
return (difference * difference) | |
}) | |
const squaredDifferencesAverage = mean(squaredDifferences) | |
return Math.sqrt(squaredDifferencesAverage) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment