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


Method "U(_,_)" is
[
	lower : number,
	upper : number
|
	divisor ::= ((1<<32)) ÷ (upper - lower)→double;
	map a pRNG through [i : integer | (i ÷ divisor) + lower]
];
 
Method "a Marsaglia polar sampler" is
[
	generator for 
		[
			yield : [double]→⊤
		|
			source ::= U(-1, 1);
			Repeat [
				x ::= take 1 from source[1];
				y ::= take 1 from source[1];
				s ::= x^2 + y^2;
				If 0 < s < 1 then
				[
					factor ::= ((-2 × ln s) ÷ s) ^ 0.5;
					yield(x × factor);
					yield(y × factor);
				];
			]
		]
];
 
// the default distribution has mean 0 and std dev 1.0, so we scale the values
sampler ::= map a Marsaglia polar sampler through [d : double | d ÷ 2.0 + 1.0];
values ::= take 1000 from sampler;