equal
deleted
inserted
replaced
71 |
71 |
72 #include <lemon/dim2.h> |
72 #include <lemon/dim2.h> |
73 ///\ingroup misc |
73 ///\ingroup misc |
74 ///\file |
74 ///\file |
75 ///\brief Mersenne Twister random number generator |
75 ///\brief Mersenne Twister random number generator |
76 /// |
|
77 ///\author Balazs Dezso |
|
78 |
76 |
79 namespace lemon { |
77 namespace lemon { |
80 |
78 |
81 namespace _random_bits { |
79 namespace _random_bits { |
82 |
80 |
514 /// |
512 /// |
515 /// The lemon provides a global instance of the random number |
513 /// The lemon provides a global instance of the random number |
516 /// generator which name is \ref lemon::rnd "rnd". Usually it is a |
514 /// generator which name is \ref lemon::rnd "rnd". Usually it is a |
517 /// good programming convenience to use this global generator to get |
515 /// good programming convenience to use this global generator to get |
518 /// random numbers. |
516 /// random numbers. |
519 /// |
|
520 /// \author Balazs Dezso |
|
521 class Random { |
517 class Random { |
522 private: |
518 private: |
523 |
519 |
524 // architecture word |
520 // Architecture word |
525 typedef unsigned long Word; |
521 typedef unsigned long Word; |
526 |
522 |
527 _random_bits::RandomCore<Word> core; |
523 _random_bits::RandomCore<Word> core; |
528 _random_bits::BoolProducer<Word> bool_producer; |
524 _random_bits::BoolProducer<Word> bool_producer; |
529 |
525 |
721 } while(S>=1); |
717 } while(S>=1); |
722 return std::sqrt(-2*std::log(S)/S)*V1; |
718 return std::sqrt(-2*std::log(S)/S)*V1; |
723 } |
719 } |
724 /// Gauss distribution with given mean and standard deviation |
720 /// Gauss distribution with given mean and standard deviation |
725 |
721 |
|
722 /// Gauss distribution with given mean and standard deviation |
726 /// \sa gauss() |
723 /// \sa gauss() |
727 /// |
|
728 double gauss(double mean,double std_dev) |
724 double gauss(double mean,double std_dev) |
729 { |
725 { |
730 return gauss()*std_dev+mean; |
726 return gauss()*std_dev+mean; |
731 } |
727 } |
732 |
728 |
812 /// |
808 /// |
813 |
809 |
814 ///@{ |
810 ///@{ |
815 |
811 |
816 /// Uniform distribution on the full unit circle. |
812 /// Uniform distribution on the full unit circle. |
|
813 |
|
814 /// Uniform distribution on the full unit circle. |
|
815 /// |
817 dim2::Point<double> disc() |
816 dim2::Point<double> disc() |
818 { |
817 { |
819 double V1,V2; |
818 double V1,V2; |
820 do { |
819 do { |
821 V1=2*real<double>()-1; |
820 V1=2*real<double>()-1; |