(1) ISTM that the + 0.5 which remains in the PoissonRand computation comes
from the previous integer approach and is not needed here. If I'm not
mistaken the formula should be plain:
-log(uniform) * center
No. The +0.5 is to round the result to the nearest integer, instead of
truncating it down.
Hmmm... probably ok. I'll have to think about it a bit.
In that case, it seems much clearer to do: "round(-log(uniform) * xxx)"
instead of relying on the truncation of the cast.
(2) I'm not sure of the name "center", I think that "lambda" or
"mean" would be more appropriate.
(shrug), I guess. The comment says that it's the value the average of a
series values is centered on, so "center" doesn't seem too bad. I guess the
mathematically accurate term would be "expected value".
The word "center" does not appear once of the wikipedia page about
"Poisson distribution". Its "mean" is called "lambda" (or rather λ:-) all
over the place. I find "expected value" rather too generic, but it is
better than "center".
(3) I wish that the maximum implied multiplier could be explicitely
documented in the source code. From pg_rand48 source code, I think
that it is 33.27106466687737
Oh, ok. That's an even smaller multiplier than I got just by feeding DBL_MIN
to the formula. I don't think that's worth worrying about. That might change
if the implementation of pg_erand48() is changed, so I'm a bit reluctant to
state it explicitly.
I think that it is an important information, so it deserves to appear.
If pg_erand48 implementation changes, it should not be called "48",
because the max value and the above multiplier limit is completely linked
to the "16*3=48" structure of the random construction.
If the code change then the comments need be updated, that is life.
--
Fabien.
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers