Skip to content

Instantly share code, notes, and snippets.

@tmcw
Last active December 18, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/5789934 to your computer and use it in GitHub Desktop.
Save tmcw/5789934 to your computer and use it in GitHub Desktop.
Simple Statistics Play Snippet
void require('http://bit.ly/ss-js');
// numbers from 1 to 100
var myData = [];
for (var i = 0; i < 99; i++) {
myData[i] = i + 1;
}
ss.mean(myData);
ss.min(myData);
ss.quantile(myData , 0.2);
// points from 1,1 to 100,50
var myPoints = [];
for (var i = 0; i < 99; i++) {
myPoints[i] = [i + 1, (i + 1)/2];
}
ss.linear_regression()
.data(myPoints)
.line()(50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment