Number of normals N = 619x
(HTML5 canvas support required)

JavaScript has only provided a uniform random variable Math.random() and a normal random number is sometimes a necessary one to have. There is a polar method to simulate normal RV from uniform RV in A First Course of Probability by Sheldon Ross (pp. 464, 6ed):

  1. Generate random numbers U1 and U2.
  2. Set V1=2U1-1,V2=2U2-1,S=V12+V22.
  3. If S<1, return step 1.
  4. Return the independent unit normals X= -2log S SV1,Y= -2log S SV2.

Here is the (almost) equivalent code in JavaScript:

function normal_random(mean, variance) {
  if (mean == undefined)
    mean = 0.0;
  if (variance == undefined)
    variance = 1.0;
  var V1, V2, S;
  do {
    var U1 = Math.random();
    var U2 = Math.random();
    V1 = 2 * U1 - 1;
    V2 = 2 * U2 - 1;
    S = V1 * V1 + V2 * V2;
  } while (S > 1);

  X = Math.sqrt(-2 * Math.log(S) / S) * V1;
//Y = Math.sqrt(-2 * Math.log(S) / S) * V2;
  X = mean + Math.sqrt(variance) * X;
//Y = mean + Math.sqrt(variance) * Y ;
  return X;
}

The following figure is N=619×100000:

http://farm5.static.flickr.com/4146/4991416908_34f661f146_z.jpg