Normally Distributed Pseudorandom Numbers

This program generates Normally Distributed Pseudorandom Numbers with mean zero and variance one.

It does this by using the built-in Math.random function which generates Uniformly Distributed Pseudorandom Numbers in the interval [0, 1).

These are then transformed to Normally Distributed Pseudorandom Numbers by using the Inverse Normal Distribution Function.

See the section "Generating values from normal distribution" in the Wikipedia article Normal distribution.

The Inverse Normal Distribution Function is implemented by using a pre-computed table of values with linear interpolation. The generated values lie in the range [-4.864687, +4.864687].

The program displays the mean and variance for the number of samples chosen.

The JavaScript code used (invF2.js and an older C++ version invF2.c) can be downloaded here.

Enter Number of Samples


Results




An alternative simpler program can be found here.


Last updated Saturday, April 22, 2017.


Valid HTML 4.01 Transitional