demo/js/npgmain.js
function randn(mean, variance) {
  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;
  X = mean + Math.sqrt(variance) * X;
  return X;
}
function randn(mean, variance) {
  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;
  X = mean + Math.sqrt(variance) * X;
  return X;
}
function randn ( mean , variance ) { 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 ; X = mean + Math . sqrt ( variance ) * X ; return X ; }
normal distribution random number
normal distribution random number