Changeset 2356:57c316cb868b in lemon0.x
 Timestamp:
 02/07/07 19:07:10 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@3156
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/random.h
r2355 r2356 625 625 } 626 626 627 ///\name Nonuniform distributions 628 /// 629 630 ///@{ 631 627 632 /// \brief Returns a random bool 628 633 /// … … 635 640 636 641 /// Standard Gauss distribution. 637 /// \ todo Currently it uses the socalles "polar technique" to generate638 /// randomdistribution.639 /// Probably, the "Ziggurat" method should rather be used.642 /// \note The Cartesian form of the BoxMuller 643 /// transformation is used to generate a random normal distribution. 644 /// \todo Consider using the "ziggurat" method instead. 640 645 double gauss() 641 646 { … … 648 653 return std::sqrt(2*std::log(S)/S)*V1; 649 654 } 650 /// Gauss distribution with given variance and mean 0 651 double gauss(double var) 655 /// Gauss distribution with given standard deviation and mean 0 656 657 /// \sa gauss() 658 /// 659 double gauss(double std_dev) 652 660 { 653 return gauss()*var; 654 } 655 /// Gauss distribution with given variance and mean 656 double gauss(double var,double mean) 661 return gauss()*std_dev; 662 } 663 /// Gauss distribution with given mean and standard deviation 664 665 /// \sa gauss() 666 /// 667 double gauss(double mean,double std_dev) 657 668 { 658 return gauss()*var+mean; 659 } 660 661 double exponential(double lambda) 669 return gauss()*std_dev+mean; 670 } 671 672 /// Exponential distribution with given mean 673 674 /// This function generates an exponential distribution random number 675 /// with mean <tt>1/lambda</tt>. 676 /// 677 double exponential(double lambda=1.0) 662 678 { 663 679 return log(real<double>())/lambda; 664 680 } 681 682 ///@} 665 683 666 684 };
Note: See TracChangeset
for help on using the changeset viewer.