# HG changeset patch # User alpar # Date 1170871630 0 # Node ID 57c316cb868ba7ca4c2767a853e437ce17021e4f # Parent ac0d843b8873cb82bb26966c110f75070b642ed1 Further doc improvements diff -r ac0d843b8873 -r 57c316cb868b lemon/random.h --- a/lemon/random.h Tue Feb 06 19:16:26 2007 +0000 +++ b/lemon/random.h Wed Feb 07 18:07:10 2007 +0000 @@ -624,6 +624,11 @@ return _random_bits::BoolConversion::convert(core); } + ///\name Nonuniform distributions + /// + + ///@{ + /// \brief Returns a random bool /// /// It returns a random bool with given probability of true result @@ -634,9 +639,9 @@ /// Standard Gauss distribution /// Standard Gauss distribution. - /// \todo Currently it uses the so-calles "polar technique" to generate - /// random distribution. - /// Probably, the "Ziggurat" method should rather be used. + /// \note The Cartesian form of the Box-Muller + /// transformation is used to generate a random normal distribution. + /// \todo Consider using the "ziggurat" method instead. double gauss() { double V1,V2,S; @@ -647,21 +652,34 @@ } while(S>=1); return std::sqrt(-2*std::log(S)/S)*V1; } - /// Gauss distribution with given variance and mean 0 - double gauss(double var) + /// Gauss distribution with given standard deviation and mean 0 + + /// \sa gauss() + /// + double gauss(double std_dev) { - return gauss()*var; + return gauss()*std_dev; } - /// Gauss distribution with given variance and mean - double gauss(double var,double mean) + /// Gauss distribution with given mean and standard deviation + + /// \sa gauss() + /// + double gauss(double mean,double std_dev) { - return gauss()*var+mean; + return gauss()*std_dev+mean; } - double exponential(double lambda) + /// Exponential distribution with given mean + + /// This function generates an exponential distribution random number + /// with mean 1/lambda. + /// + double exponential(double lambda=1.0) { return -log(real())/lambda; } + + ///@} };