Skip to content

Instantly share code, notes, and snippets.

@dtsn
dtsn / standard-deviation.js
Created May 26, 2016 08:34
How to get the mean and standard deviation from an array in JavaScript
var arr = [1,1,1,2,3,4,5,3,3,3,4,5,6,3,2,4,6];
// first work out the mean
var mean = arr.reduce(function (p, c) {
return p + c;
}) / arr.length;
// now the stanard deviation
var standardDeviation = Math.sqrt(arr.map(function (l) {
return Math.pow(l - mean, 2);
@dtsn
dtsn / 0_reuse_code.js
Last active February 27, 2017 11:29
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console