lemon/random.h
changeset 82 bce6c8f93d10
parent 62 4790635473ef
child 92 5d4decd1b870
equal deleted inserted replaced
7:17f797285a1a 8:c0a706ad07c4
    65 #include <algorithm>
    65 #include <algorithm>
    66 #include <iterator>
    66 #include <iterator>
    67 #include <vector>
    67 #include <vector>
    68 
    68 
    69 #include <ctime>
    69 #include <ctime>
    70 #include <cmath>
    70 
    71 
    71 #include <lemon/math.h>
    72 #include <lemon/dim2.h>
    72 #include <lemon/dim2.h>
       
    73 
    73 ///\ingroup misc
    74 ///\ingroup misc
    74 ///\file
    75 ///\file
    75 ///\brief Mersenne Twister random number generator
    76 ///\brief Mersenne Twister random number generator
    76 
    77 
    77 namespace lemon {
    78 namespace lemon {
   757     ///
   758     ///
   758     double gamma(double k,double theta=1.0)
   759     double gamma(double k,double theta=1.0)
   759     {
   760     {
   760       double xi,nu;
   761       double xi,nu;
   761       const double delta = k-std::floor(k);
   762       const double delta = k-std::floor(k);
   762       const double v0=M_E/(M_E-delta);
   763       const double v0=E/(E-delta);
   763       do {
   764       do {
   764 	double V0=1.0-real<double>();
   765 	double V0=1.0-real<double>();
   765 	double V1=1.0-real<double>();
   766 	double V1=1.0-real<double>();
   766 	double V2=1.0-real<double>();
   767 	double V2=1.0-real<double>();
   767 	if(V2<=v0) 
   768 	if(V2<=v0)