$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] [Random] Sigma equal to zero in normal distribution.
From: er (erwann.rogard_at_[hidden])
Date: 2009-03-11 12:18:29
Rodolfo Federico Gamarra wrote:
> Hi all,
> 
> The documentation for the normal distribution
> 
> (http://www.boost.org/doc/libs/1_38_0/libs/random/random-distributions.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 "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
As a user, that seems like a reasonable behavior.
It might sometimes be more convenient to set sigma = 0 than to use a 
specific class for a degenerate distribution. The sample mean has 
asymptotic sd = 0, after all.
> 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