
Boost Users : 
Subject: [Boostusers] [Random] Sigma equal to zero in normal distribution.
From: Rodolfo Federico Gamarra (rgamarra_at_[hidden])
Date: 20090311 11:24:04
Hi all,
The documentation for the normal distribution
(http://www.boost.org/doc/libs/1_38_0/libs/random/randomdistributions.html#normal_distribution)
states:
"Members
explicit normal_distribution(const result_type& mean = 0, const
result_type& sigma = 1);
Requires: sigma > 0"
In the actual code of this constructor
(http://www.boost.org/doc/libs/1_38_0/boost/random/normal_distribution.hpp)
it can be seen
"assert(_sigma >= result_type(0));".
That is, acepts sigma == 0.
Indeed, there's no "divisionbyzero" or so, because the method that
is used ("BoxMuller") 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
Boostusers 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