Created
October 17, 2015 09:10
-
-
Save venning/b6593f965773985f923f to your computer and use it in GitHub Desktop.
Standard Deviation with lodash
This file contains 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
// NOTE requires lodash v3.4.0+ (for _.sum) and Node 4.0+ (for arrow function) | |
var _ = require('lodash'); | |
function σ (array) { | |
var avg = _.sum(array) / array.length; | |
return Math.sqrt(_.sum(_.map(array, (i) => Math.pow((i - avg), 2))) / array.length); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment