# Ticket #164: 0badf3bb38c2.patch

File 0badf3bb38c2.patch, 3.4 KB (added by Peter Kovacs, 14 years ago)
• ## lemon/random.h

```# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1225201677 -3600
# Node ID 0badf3bb38c2a0ef9cb4c0dc1c2bd994979d043a
# Parent  2593e163e407403990ba8f4323f684190a625a62
Minor doc improvements

diff --git a/lemon/random.h b/lemon/random.h```
 a /// /// @{ ///\name Initialization /// /// @{ /// \brief Default constructor /// /// Constructor with constant seeding. return real() * (b - a) + a; } /// @} ///\name Uniform distributions /// /// @{ /// \brief Returns a random real number from the range [0, 1) /// /// It returns a random double from the range [0, 1). return _random_bits::IntConversion::convert(core); } /// @} unsigned int uinteger() { return uinteger(); } ///\name Non-uniform distributions /// ///@{ /// \brief Returns a random bool /// \brief Returns a random bool with given probability of true result. /// /// It returns a random bool with given probability of true result. bool boolean(double p) { return operator()() < p; } /// Standard Gauss distribution /// Standard normal (Gauss) distribution /// Standard Gauss distribution. /// Standard normal (Gauss) distribution. /// \note The Cartesian form of the Box-Muller /// transformation is used to generate a random normal distribution. double gauss() } while(S>=1); return std::sqrt(-2*std::log(S)/S)*V1; } /// Gauss distribution with given mean and standard deviation /// Normal (Gauss) distribution with given mean and standard deviation /// Gauss distribution with given mean and standard deviation. /// Normal (Gauss) distribution with given mean and standard deviation. /// \sa gauss() double gauss(double mean,double std_dev) { /// standard deviation. The return value can direcly be passed to /// lognormal(). std::pair lognormalParamsFromMD(double mean, double std_dev) double std_dev) { double fr=std_dev/mean; fr*=fr; return std::pair(std::log(mean)-lg/2.0,std::sqrt(lg)); } /// Lognormal distribution with given mean and standard deviation /// Lognormal distribution with given mean and standard deviation. /// double lognormalMD(double mean,double std_dev) { return lognormal(lognormalParamsFromMD(mean,std_dev)); } /// Exponential distribution with given mean /// This function generates an exponential distribution random number ///\name Two dimensional distributions /// ///@{ /// Uniform distribution on the full unit circle } while(V1*V1+V2*V2>=1); return dim2::Point(V1,V2); } /// A kind of two dimensional Gauss distribution /// A kind of two dimensional normal (Gauss) distribution /// This function provides a turning symmetric two-dimensional distribution. /// Both coordinates are of standard normal distribution, but they are not