Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 3, 2015 23:13
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 mattlundstrom/8d605a11ccfafe3822cf to your computer and use it in GitHub Desktop.
Save mattlundstrom/8d605a11ccfafe3822cf to your computer and use it in GitHub Desktop.
function randomRange(min, max) {
return min + Math.random() * (max - min);
}
function randomWeightedRange(min, max, expo) {
return toDecimal(((Math.random() * (max - min)) + min), expo);
}
function randomInt(min, max) {
return Math.floor(min + Math.random() * (max - min + 1));
}
function randomDistribution(min, max, iterations) {
var total = 0;
for(var i = 0; i < iterations; i += 1) {
total += utils.randomRange(min, max);
}
return total / iterations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment