JavaScript:
//*************************************************************************
//* Returns random numbers from Standard Normal Distribution **
//*************************************************************************
double gauss() {
double fac;
double r = 99;
double V1 = 0;
double V2 = 0;
while (r >= 1) {
V1 = 2 * Math.random() - 1;
V2 = 2 * Math.random() - 1;
r = Math.pow(V1, 2) + Math.pow(V2, 2);
}
fac = Math.sqrt(-2 * Math.log(r) / r);
return V2 * fac;
}