Boost logo

Boost Users :

Subject: [Boost-users] [Random] Sigma equal to zero in normal distribution.
From: Rodolfo Federico Gamarra (rgamarra_at_[hidden])
Date: 2009-03-11 11:24:04

Hi all,

The documentation for the normal distribution



    explicit normal_distribution(const result_type& mean = 0, const
result_type& sigma = 1);
Requires: sigma > 0"

In the actual code of this constructor


it can be seen

"assert(_sigma >= result_type(0));".

That is, acepts sigma == 0.

Indeed, there's no "division-by-zero" or so, because the method that
is used ("Box-Muller") doesn't actually divide by sigma:

return _cached_rho * (_valid ? cos(result_type(2)*pi*_r1) :
sin(result_type(2)*pi*_r1)) * _sigma + _mean;

So, in this case, the numbers will be all equal to _mean. From the
mathematical point of view there's no such thing as a normal
distribution with sigma equal to zero; but, computationally, may be
handy to allow that.

What's the expected behavior? Is there a typo in the docs? Or is it
that the case sigma equal to zero is indeed undefined (so that
anything could happen)?

Thanks in advance, cheers.

Rodolfo Federico Gamarra

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at