Skip to content

Instantly share code, notes, and snippets.

@venning
Created October 17, 2015 09:10
Show Gist options
  • Save venning/b6593f965773985f923f to your computer and use it in GitHub Desktop.
Save venning/b6593f965773985f923f to your computer and use it in GitHub Desktop.
Standard Deviation with lodash
// 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