COIN-OR::LEMON - Graph Library

Changeset 378:80ec623f529f in lemon-1.2 for lemon


Ignore:
Timestamp:
11/11/08 11:25:57 (15 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Parents:
376:4b2382fd80ef (diff), 377:c4aa9f097ef1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r340 r378  
    689689    }
    690690
    691     /// \brief Returns a random real number the range [0, b)
    692     ///
    693     /// It returns a random real number from the range [0, b).
    694     template <typename Number>
    695     Number real(Number b) {
    696       return real<Number>() * b;
    697     }
    698 
    699     /// \brief Returns a random real number from the range [a, b)
    700     ///
    701     /// It returns a random real number from the range [a, b).
    702     template <typename Number>
    703     Number real(Number a, Number b) {
    704       return real<Number>() * (b - a) + a;
    705     }
    706 
    707691    /// \brief Returns a random real number from the range [0, 1)
    708692    ///
     
    715699    ///
    716700    /// It returns a random real number from the range [0, b).
    717     template <typename Number>
    718     Number operator()(Number b) {
    719       return real<Number>() * b;
     701    double operator()(double b) {
     702      return real<double>() * b;
    720703    }
    721704
     
    723706    ///
    724707    /// It returns a random real number from the range [a, b).
    725     template <typename Number>
    726     Number operator()(Number a, Number b) {
    727       return real<Number>() * (b - a) + a;
     708    double operator()(double a, double b) {
     709      return real<double>() * (b - a) + a;
    728710    }
    729711
  • 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.