Task

Generate a collection filled with   1000   normally distributed random (or pseudo-random) numbers
with a mean of   1.0   and a   standard deviation   of   0.5



Many libraries only generate uniformly distributed random numbers. If so, you may use one of these algorithms.



Related task

   Standard deviation


import extensions;
import extensions'math;
 
randomNormal()
{
    ^ cos(2 * Pi_value * randomGenerator.nextReal()) 
                      * sqrt(-2 * ln(randomGenerator.nextReal())) 
}
 
public program()
{
    real[] a := new real[](1000);
 
    real tAvg := 0;
    for (int x := 0, x < a.Length, x += 1)
    {
        a[x] := (randomNormal()) / 2 + 1;
        tAvg += a[x]
    };
 
    tAvg /= a.Length;
    console.printLine("Average: ", tAvg);
 
    real s := 0;
    for (int x := 0, x < a.Length, x += 1)
    {
        s += power(a[x] - tAvg, 2)
    };
 
    s := sqrt(s / 1000);
 
    console.printLine("Standard Deviation: ", s);
 
    console.readChar()
}