RosettaCodeData/Task/Random-numbers/XPL0/random-numbers.xpl0

13 lines
335 B
Plaintext

define PI = 3.14159265358979323846;
func real DRand; \Uniform distribution, [0..1]
return float(Ran(1_000_000)) / 1e6;
func real RandomNormal; \Normal distribution, centered on 0, std dev 1
return sqrt(-2.*Log(DRand)) * Cos(2.*PI*DRand);
int I;
real Rands(1000);
for I:= 0 to 1000-1 do
Rands(I):= 1.0 + 0.5*RandomNormal