COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r280 r340  
    541541    /// @{
    542542
    543     ///\name Initialization
    544     ///
    545     /// @{
    546 
    547543    /// \brief Default constructor
    548544    ///
     
    709705    }
    710706
    711     /// @}
    712 
    713     ///\name Uniform distributions
    714     ///
    715     /// @{
    716 
    717707    /// \brief Returns a random real number from the range [0, 1)
    718708    ///
     
    771761      return _random_bits::IntConversion<Number, Word>::convert(core);
    772762    }
    773 
    774     /// @}
    775763
    776764    unsigned int uinteger() {
     
    807795    ///\name Non-uniform distributions
    808796    ///
    809 
    810797    ///@{
    811798
    812     /// \brief Returns a random bool
     799    /// \brief Returns a random bool with given probability of true result.
    813800    ///
    814801    /// It returns a random bool with given probability of true result.
     
    817804    }
    818805
    819     /// Standard Gauss distribution
    820 
    821     /// Standard Gauss distribution.
     806    /// Standard normal (Gauss) distribution
     807
     808    /// Standard normal (Gauss) distribution.
    822809    /// \note The Cartesian form of the Box-Muller
    823810    /// transformation is used to generate a random normal distribution.
     
    832819      return std::sqrt(-2*std::log(S)/S)*V1;
    833820    }
    834     /// Gauss distribution with given mean and standard deviation
    835 
    836     /// Gauss distribution with given mean and standard deviation.
     821    /// Normal (Gauss) distribution with given mean and standard deviation
     822
     823    /// Normal (Gauss) distribution with given mean and standard deviation.
    837824    /// \sa gauss()
    838825    double gauss(double mean,double std_dev)
    839826    {
    840827      return gauss()*std_dev+mean;
     828    }
     829
     830    /// Lognormal distribution
     831
     832    /// Lognormal distribution. The parameters are the mean and the standard
     833    /// deviation of <tt>exp(X)</tt>.
     834    ///
     835    double lognormal(double n_mean,double n_std_dev)
     836    {
     837      return std::exp(gauss(n_mean,n_std_dev));
     838    }
     839    /// Lognormal distribution
     840
     841    /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of
     842    /// the mean and the standard deviation of <tt>exp(X)</tt>.
     843    ///
     844    double lognormal(const std::pair<double,double> &params)
     845    {
     846      return std::exp(gauss(params.first,params.second));
     847    }
     848    /// Compute the lognormal parameters from mean and standard deviation
     849
     850    /// This function computes the lognormal parameters from mean and
     851    /// standard deviation. The return value can direcly be passed to
     852    /// lognormal().
     853    std::pair<double,double> lognormalParamsFromMD(double mean,
     854                                                   double std_dev)
     855    {
     856      double fr=std_dev/mean;
     857      fr*=fr;
     858      double lg=std::log(1+fr);
     859      return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg));
     860    }
     861    /// Lognormal distribution with given mean and standard deviation
     862
     863    /// Lognormal distribution with given mean and standard deviation.
     864    ///
     865    double lognormalMD(double mean,double std_dev)
     866    {
     867      return lognormal(lognormalParamsFromMD(mean,std_dev));
    841868    }
    842869
     
    944971    ///\name Two dimensional distributions
    945972    ///
    946 
    947973    ///@{
    948974
     
    961987      return dim2::Point<double>(V1,V2);
    962988    }
    963     /// A kind of two dimensional Gauss distribution
     989    /// A kind of two dimensional normal (Gauss) distribution
    964990
    965991    /// This function provides a turning symmetric two-dimensional distribution.
Note: See TracChangeset for help on using the changeset viewer.