Hi Folks,
the memory leak problem not seems to be linked to the call of the "random" function. However, during the test I realized that the built-in "random" is piss poor. The test source goes at the end. You supposed to see evenly distributed numbers in the third column of the output. Try it for yourself.
miklos
___________________________________________________
program cgr; { Chaos-game test of random number generator }
const dim=100; { Change these if they are too large for you } cyc=100000000;
var c,i,j,r:integer; s:array[-dim .. dim, -dim .. dim] of integer; x,y:real;
begin
for i:= -dim to dim do for j:= -dim to dim do s[i,j]:=0;
x:=0; y:=0;
for c:= 1 to cyc do begin
r:= random(3);
case r of 0:begin x:= (x+1)/2; y:= (y+1)/2; end; 1:begin x:= (x-1)/2; y:= (y+1)/2; end; 2:begin x:= (x-1)/2; y:= (y-1)/2; end; 3:begin x:= (x+1)/2; y:= (y-1)/2; end; end;
i:= round( x*dim ); j:= round( y*dim ); inc(s[i,j]);
end;
for i:= -dim to dim do for j:= -dim to dim do writeln(i:6,j:6,s[i,j]:12);
end.
Miklos Cserzo wrote:
the memory leak problem not seems to be linked to the call of the "random" function. However, during the test I realized that the built-in "random" is piss poor. The test source goes at the end. You supposed to see evenly distributed numbers in the third column of the output. Try it for yourself.
r:= random(3);
r:= random(4);
Frank