|
Boost Users : |
From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2006-10-23 17:41:09
Thanks for the forward.
John Maddock wrote:
> Nelis Franken wrote:
>> 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());
This is -1/lambda * log(1-eng())
This matches what wikipedia shows.
>> 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())
Not quite. Our engines return values in the range [0,1)
(lower bound inclusive, upper bound exclusive).
log(0) is undefined, thus we avoid that by using (1-eng()).
Wikipedia states
"Moreover, if U is uniform on (0;1), then so is 1 â U. "
Note the interval that is open on both ends in the precondition.
I believe the boost implementation is correct here.
Thanks,
Jens
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