Boost logo

Boost Users :

From: François Duranleau (duranlef_at_[hidden])
Date: 2006-10-23 12:14:24


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

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