Changeset 2355:ac0d843b8873 in lemon0.x
 Timestamp:
 02/06/07 20:16:26 (14 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@3155
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/random.h
r2285 r2355 25 25 26 26 #include <ctime> 27 #include <cmath>28 27 #include <cmath> 29 28 … … 632 631 return operator()() < p; 633 632 } 633 634 /// Standard Gauss distribution 635 636 /// Standard Gauss distribution. 637 /// \todo Currently it uses the socalles "polar technique" to generate 638 /// random distribution. 639 /// Probably, the "Ziggurat" method should rather be used. 640 double gauss() 641 { 642 double V1,V2,S; 643 do { 644 V1=2*real<double>()1; 645 V2=2*real<double>()1; 646 S=V1*V1+V2*V2; 647 } while(S>=1); 648 return std::sqrt(2*std::log(S)/S)*V1; 649 } 650 /// Gauss distribution with given variance and mean 0 651 double gauss(double var) 652 { 653 return gauss()*var; 654 } 655 /// Gauss distribution with given variance and mean 656 double gauss(double var,double mean) 657 { 658 return gauss()*var+mean; 659 } 660 661 double exponential(double lambda) 662 { 663 return log(real<double>())/lambda; 664 } 634 665 635 666 };
Note: See TracChangeset
for help on using the changeset viewer.