COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r377 r378  
    541541    /// @{
    542542
    543     ///\name Initialization
    544     ///
    545     /// @{
    546 
    547543    /// \brief Default constructor
    548544    ///
     
    693689    }
    694690
    695     /// @}
    696 
    697     ///\name Uniform distributions
    698     ///
    699     /// @{
    700 
    701691    /// \brief Returns a random real number from the range [0, 1)
    702692    ///
     
    753743      return _random_bits::IntConversion<Number, Word>::convert(core);
    754744    }
    755 
    756     /// @}
    757745
    758746    unsigned int uinteger() {
     
    789777    ///\name Non-uniform distributions
    790778    ///
    791 
    792779    ///@{
    793780
    794     /// \brief Returns a random bool
     781    /// \brief Returns a random bool with given probability of true result.
    795782    ///
    796783    /// It returns a random bool with given probability of true result.
     
    799786    }
    800787
    801     /// Standard Gauss distribution
    802 
    803     /// Standard Gauss distribution.
     788    /// Standard normal (Gauss) distribution
     789
     790    /// Standard normal (Gauss) distribution.
    804791    /// \note The Cartesian form of the Box-Muller
    805792    /// transformation is used to generate a random normal distribution.
     
    814801      return std::sqrt(-2*std::log(S)/S)*V1;
    815802    }
    816     /// Gauss distribution with given mean and standard deviation
    817 
    818     /// Gauss distribution with given mean and standard deviation.
     803    /// Normal (Gauss) distribution with given mean and standard deviation
     804
     805    /// Normal (Gauss) distribution with given mean and standard deviation.
    819806    /// \sa gauss()
    820807    double gauss(double mean,double std_dev)
    821808    {
    822809      return gauss()*std_dev+mean;
     810    }
     811
     812    /// Lognormal distribution
     813
     814    /// Lognormal distribution. The parameters are the mean and the standard
     815    /// deviation of <tt>exp(X)</tt>.
     816    ///
     817    double lognormal(double n_mean,double n_std_dev)
     818    {
     819      return std::exp(gauss(n_mean,n_std_dev));
     820    }
     821    /// Lognormal distribution
     822
     823    /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of
     824    /// the mean and the standard deviation of <tt>exp(X)</tt>.
     825    ///
     826    double lognormal(const std::pair<double,double> &params)
     827    {
     828      return std::exp(gauss(params.first,params.second));
     829    }
     830    /// Compute the lognormal parameters from mean and standard deviation
     831
     832    /// This function computes the lognormal parameters from mean and
     833    /// standard deviation. The return value can direcly be passed to
     834    /// lognormal().
     835    std::pair<double,double> lognormalParamsFromMD(double mean,
     836                                                   double std_dev)
     837    {
     838      double fr=std_dev/mean;
     839      fr*=fr;
     840      double lg=std::log(1+fr);
     841      return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg));
     842    }
     843    /// Lognormal distribution with given mean and standard deviation
     844
     845    /// Lognormal distribution with given mean and standard deviation.
     846    ///
     847    double lognormalMD(double mean,double std_dev)
     848    {
     849      return lognormal(lognormalParamsFromMD(mean,std_dev));
    823850    }
    824851
     
    926953    ///\name Two dimensional distributions
    927954    ///
    928 
    929955    ///@{
    930956
     
    943969      return dim2::Point<double>(V1,V2);
    944970    }
    945     /// A kind of two dimensional Gauss distribution
     971    /// A kind of two dimensional normal (Gauss) distribution
    946972
    947973    /// This function provides a turning symmetric two-dimensional distribution.
Note: See TracChangeset for help on using the changeset viewer.