|
Boost Users : |
From: Nelis Franken (nfranken_at_[hidden])
Date: 2006-10-23 10:39:22
Hi,
I've been looking into statistical distributions, and while comparing
Wikipedia's mathematical formulation and Boost's implementation of the
Exponential Distribution, I have found two points of interest. Before
continuing, I just need to add that I'm not a statistician or a
mathematician, so any errors either mathematical or in interpretation below
are my own.
The Wikipedia reference:
http://en.wikipedia.org/wiki/Exponential_distribution
The Boost implementation (line 54 of exponential_distribution.hpp)
-result_type(1) / _lambda * log(result_type(1)-eng());
Where the eng() call generates a uniform random number.
The first, less critical point: If eng() is uniform, then so is (1 - eng()),
which allows for the simplification of the statement passed to log() from:
log(result_type(1)-eng())
to
log(eng())
The second, more critical point: The implementation does not seem to be the
correct inverse of the original function. Boost's implementation (with above
modification) is:
-result_type(1) / _lambda * log(eng());
But should actually be:
-log(eng()) / _lamda;
Could someone perhaps clarify the above? Again, apologies if my
interpretations were wrong.
Kind regards,
Nelis Franken
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net