COIN-OR::LEMON - Graph Library

Changeset 339:2593e163e407 in lemon-main


Ignore:
Timestamp:
06/19/08 18:33:06 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Children:
340:0badf3bb38c2, 341:f8832dc16d45
Phase:
public
Message:

Lognormal distribution added (#102)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r280 r339  
    841841    }
    842842
     843    /// Lognormal distribution
     844
     845    /// Lognormal distribution. The parameters are the mean and the standard
     846    /// deviation of <tt>exp(X)</tt>.
     847    ///
     848    double lognormal(double n_mean,double n_std_dev)
     849    {
     850      return std::exp(gauss(n_mean,n_std_dev));
     851    }
     852    /// Lognormal distribution
     853
     854    /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of
     855    /// the mean and the standard deviation of <tt>exp(X)</tt>.
     856    ///
     857    double lognormal(const std::pair<double,double> &params)
     858    {
     859      return std::exp(gauss(params.first,params.second));
     860    }
     861    /// Compute the lognormal parameters from mean and standard deviation
     862
     863    /// This function computes the lognormal parameters from mean and
     864    /// standard deviation. The return value can direcly be passed to
     865    /// lognormal().
     866    std::pair<double,double> lognormalParamsFromMD(double mean,
     867                                                   double std_dev)
     868    {
     869      double fr=std_dev/mean;
     870      fr*=fr;
     871      double lg=std::log(1+fr);
     872      return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg));
     873    }
     874    /// Lognormal distribution with given mean and standard deviation
     875   
     876    /// Lognormal distribution with given mean and standard deviation.
     877    ///
     878    double lognormalMD(double mean,double std_dev)
     879    {
     880      return lognormal(lognormalParamsFromMD(mean,std_dev));
     881    }
     882   
    843883    /// Exponential distribution with given mean
    844884
Note: See TracChangeset for help on using the changeset viewer.