Boost logo

Boost Users :

Subject: Re: [Boost-users] Box-Muller - normal distributed random numbers
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-06-21 17:01:30


AMDG

Matthias Fuchs wrote:
> I wonder why _cached_rho is calclulated this way:
>
> sqrt(-result_type(2) * log(result_type(1)-_r2));
>
> in normal_distribution.hpp:70 and not
>
> sqrt(-result_type(2) * log(_r2));
>
> So I don't understand why there is "result_type(1) - _r2" instead of just
> "_r2".
>

_r2 is in the range [0, 1). log(0) is a bad idea, so
the algorithm uses 1-_r2 to flip the range to (0, 1].

In Christ,
Steven Watanabe


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