Created
June 3, 2015 23:13
-
-
Save mattlundstrom/8d605a11ccfafe3822cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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