Skip to content

Instantly share code, notes, and snippets.

@flengyel
Created December 4, 2013 01:43
Show Gist options
  • Save flengyel/7780945 to your computer and use it in GitHub Desktop.
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].
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