Skip to content

Instantly share code, notes, and snippets.

@brycebaril
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save brycebaril/9591246 to your computer and use it in GitHub Desktop.

Select an option

Save brycebaril/9591246 to your computer and use it in GitHub Desktop.
var stats = require("stats-lite")
var dice = require("droll")
var rolls = []
for (var i = 0; i < 3000; i++) {
rolls.push(dice.roll("2d6").total)
}
console.log("sum: %s", stats.sum(rolls))
console.log("mean: %s", stats.mean(rolls))
console.log("median: %s", stats.median(rolls))
console.log("mode: %s", stats.mode(rolls))
console.log("variance: %s", stats.variance(rolls))
console.log("standard deviation: %s", stats.stdev(rolls))
console.log("85th percentile: %s", stats.percentile(rolls, 0.85))
var stats = require("stats-lite")
var data = ["cat", 0, 1]
// The 'cat' is filtered out prior to operations.
console.log(stats.sum(data))
console.log(stats.mean(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment