COIN-OR::LEMON - Graph Library

Changeset 11:ea5945b2da9c in lemon for lemon


Ignore:
Timestamp:
12/21/07 02:32:24 (16 years ago)
Author:
Alpar Juttner <alpar@…>
Branch:
default
Phase:
public
Message:

Pareto and Weibull random distributions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r10 r11  
    738738    double exponential(double lambda=1.0)
    739739    {
    740       return -std::log(real<double>())/lambda;
     740      return -std::log(1.0-real<double>())/lambda;
    741741    }
    742742
     
    783783    }
    784784   
     785    /// Weibull distribution
     786
     787    /// This function generates a Weibull distribution random number.
     788    ///
     789    ///\param k shape parameter (<tt>k>0</tt>)
     790    ///\param lambda scale parameter (<tt>lambda>0</tt>)
     791    ///
     792    double weibull(double k,double lambda)
     793    {
     794      return lambda*pow(-std::log(1.0-real<double>()),1.0/k);
     795    } 
     796     
     797    /// Pareto distribution
     798
     799    /// This function generates a Pareto distribution random number.
     800    ///
     801    ///\param x_min location parameter (<tt>x_min>0</tt>)
     802    ///\param k shape parameter (<tt>k>0</tt>)
     803    ///
     804    ///\warning This function used inverse transform sampling, therefore may
     805    ///suffer from numerical unstability.
     806    ///
     807    ///\todo Implement a numerically stable method
     808    double pareto(double x_min,double k)
     809    {
     810      return x_min*pow(1.0-real<double>(),1.0/k);
     811    } 
    785812     
    786813    ///@}
Note: See TracChangeset for help on using the changeset viewer.