Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Random-numbers/Seed7/random-numbers.seed7
Normal file
25
Task/Random-numbers/Seed7/random-numbers.seed7
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "float.s7i";
|
||||
include "math.s7i";
|
||||
|
||||
const func float: frand is func # Uniform distribution, (0..1]
|
||||
result
|
||||
var float: frand is 0.0;
|
||||
begin
|
||||
repeat
|
||||
frand := rand(0.0, 1.0);
|
||||
until frand <> 0.0;
|
||||
end func;
|
||||
|
||||
const func float: randomNormal is # Normal distribution, centered on 0, std dev 1
|
||||
return sqrt(-2.0 * log(frand)) * cos(2.0 * PI * frand);
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: i is 0;
|
||||
var array float: rands is 1000 times 0.0;
|
||||
begin
|
||||
for i range 1 to length(rands) do
|
||||
rands[i] := 1.0 + 0.5 * randomNormal;
|
||||
end for;
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue