
23 Oct
2006
23 Oct
'06
4:14 p.m.
On Mon, 23 Oct 2006, Nelis Franken wrote: [...]
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())
If I remember correctly, eng() returns a value in the interval [0,1), which poses a problem for log at 0. But 1-eng() returns a value in the interval (0,1], which is ok for log. -- François Duranleau LIGUM, Université de Montréal