Created
December 4, 2013 01:43
-
-
Save flengyel/7780945 to your computer and use it in GitHub Desktop.
Approximation to normal distribution by summing three uniformly distributed random numbers, normalized to [-1,1].
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 rnd_snd() { | |
return (Math.random()*2-1)+(Math.random()*2-1)+(Math.random()*2-1); | |
} | |
function rnd(mean, stdev) { | |
return Math.round(rnd_snd()*stdev+mean); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment