|
![](/i/fill.gif) |
Jay Fox wrote:
> "Phoenex" <rib### [at] sapo pt> wrote:
>> The algorithm PRNGAlvo was put in this discussion, always with an atti
tude of
>> helping, and to receive critics about it.
>
> Well, in the spirit of constructive analysis, I will say that Alvo is p
robably
> better than a 32-bit LCG.
>
> Just to set the record straight, Phoenex is right: Alvo is NOT an LCG.
> Technically, anyway, and depending on how strictly you define an LCG.
>
I beg to disagree. An LCG is called that because it uses a linear
equation followed by a congruence. The Alvo algorithm fits that
description.
However, I will admit that for properly chosen seeds, Alvo is
probably better than an integer LCG of the same size. This is mostly
due to the rounding errors that occur with floating point and won't
occur with integers. This raises an additional issue: that of
repeatability. Depending on your platform and compiler, you will get
different rounding errors and therefore different sequences.
Depending on your application, this may be a showstopper. For
example, with the exact same source code, I get different values:
> gcc -O3 -mfpmath=sse -lm -o alvo alvo.c
> ./alvo
0.149126
> gcc -O3 -mfpmath=387 -lm -o alvo alvo.c
> ./alvo
0.917551
I've attached the code if someone wants to play with it. Note that
in 387 mode (i.e *not* the default here contrary to what I thought),
you can also play with the setRoundMode and setPrecision functions
to get yet different results.
Jerome
--
mailto:jeb### [at] free fr
http://jeberger.free.fr
Jabber: jeb### [at] jabber fr
Post a reply to this message
Attachments:
Download 'us-ascii' (1 KB)
|
![](/i/fill.gif) |