Skip to content

Instantly share code, notes, and snippets.

@supereggbert
Created April 26, 2018 15:43
Show Gist options
  • Save supereggbert/fe5fb7b1fc30609e983b0207ae136707 to your computer and use it in GitHub Desktop.
Save supereggbert/fe5fb7b1fc30609e983b0207ae136707 to your computer and use it in GitHub Desktop.
Simple Random Gaussian Function in Javascript
function gaussianRandom(mean,sigma){
var u = Math.random();
return (u%1e-8>5e-9?1:-1)*Math.sqrt(-Math.log(Math.max(1e-9,u)))*sigma+mean;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment