[fpc-pascal] Re: Why is Random(255) some 529x slower compared to Delphi 7?
Marco van de Voort
marcov at stack.nl
Fri Dec 9 13:34:43 CET 2011
In our previous episode, Dimitri Smits said:
>
> Randomize() is supposed to be called only once to seed the generator with an initial value.
>
> If you made it something like so:
>
> begin
> for i := 0 to 1000 do
> begin
> randomize();
> pixel[random(screenwidth),random(screenheight)]:= clSomeColor;
> end;
> end;
>
> then you seed with a timestamp before randoming and your distribution does
> not change much with a lcg. Not the fault of the algorithm itself, just
> your mistake of doing the randomize in the loop itself (like you mentioned
> yourself).
(specially since high quality rng's might call OS dependent sources for
initial entropy in that first call)
More information about the fpc-pascal
mailing list