The Normal (or Gaussian) distribution is a frequently used distribution in statistics. While most programming languages provide a uniformly distributed random number generator, one can derive normally distributed random numbers from a uniform generator.



The task

 Take a uniform random number generator and create a large (you decide how large) set of numbers that follow a normal (Gaussian) distribution. Calculate the dataset's mean and standard deviation, and show a histogram of the data.
 Mention any native language support for the generation of normally distributed random numbers.


Reference

 You may refer to code in Statistics/Basic if available.


fcn norm2{   // Box-Muller
   const PI2=(0.0).pi*2;;
   rnd:=(0.0).random.fp(1);  // random number in [0,1), using partial application
   r,a:=(-2.0*rnd().log()).sqrt(), PI2*rnd();
   return(r*a.cos(), r*a.sin());  // z0,z1
}
const N=100000, BINS=12, SIG=3, SCALE=500;
var sum=0.0,sumSq=0.0, h=BINS.pump(List(),0);	// (0,0,0,...)
fcn accum(v){
   sum+=v;
   sumSq+=v*v;
   b:=(v + SIG)*BINS/SIG/2;
   if(0<=b<BINS) h[b]+=1;
};