Changes in lemon/random.h [391:c4aa9f097ef1:392:80ec623f529f] in lemon
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/random.h
r391 r392 541 541 /// @{ 542 542 543 ///\name Initialization544 ///545 /// @{546 547 543 /// \brief Default constructor 548 544 /// … … 693 689 } 694 690 695 /// @}696 697 ///\name Uniform distributions698 ///699 /// @{700 701 691 /// \brief Returns a random real number from the range [0, 1) 702 692 /// … … 753 743 return _random_bits::IntConversion<Number, Word>::convert(core); 754 744 } 755 756 /// @}757 745 758 746 unsigned int uinteger() { … … 789 777 ///\name Nonuniform distributions 790 778 /// 791 792 779 ///@{ 793 780 794 /// \brief Returns a random bool 781 /// \brief Returns a random bool with given probability of true result. 795 782 /// 796 783 /// It returns a random bool with given probability of true result. … … 799 786 } 800 787 801 /// Standard Gaussdistribution802 803 /// Standard Gaussdistribution.788 /// Standard normal (Gauss) distribution 789 790 /// Standard normal (Gauss) distribution. 804 791 /// \note The Cartesian form of the BoxMuller 805 792 /// transformation is used to generate a random normal distribution. … … 814 801 return std::sqrt(2*std::log(S)/S)*V1; 815 802 } 816 /// Gaussdistribution with given mean and standard deviation817 818 /// Gaussdistribution with given mean and standard deviation.803 /// Normal (Gauss) distribution with given mean and standard deviation 804 805 /// Normal (Gauss) distribution with given mean and standard deviation. 819 806 /// \sa gauss() 820 807 double gauss(double mean,double std_dev) 821 808 { 822 809 return gauss()*std_dev+mean; 810 } 811 812 /// Lognormal distribution 813 814 /// Lognormal distribution. The parameters are the mean and the standard 815 /// deviation of <tt>exp(X)</tt>. 816 /// 817 double lognormal(double n_mean,double n_std_dev) 818 { 819 return std::exp(gauss(n_mean,n_std_dev)); 820 } 821 /// Lognormal distribution 822 823 /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of 824 /// the mean and the standard deviation of <tt>exp(X)</tt>. 825 /// 826 double lognormal(const std::pair<double,double> ¶ms) 827 { 828 return std::exp(gauss(params.first,params.second)); 829 } 830 /// Compute the lognormal parameters from mean and standard deviation 831 832 /// This function computes the lognormal parameters from mean and 833 /// standard deviation. The return value can direcly be passed to 834 /// lognormal(). 835 std::pair<double,double> lognormalParamsFromMD(double mean, 836 double std_dev) 837 { 838 double fr=std_dev/mean; 839 fr*=fr; 840 double lg=std::log(1+fr); 841 return std::pair<double,double>(std::log(mean)lg/2.0,std::sqrt(lg)); 842 } 843 /// Lognormal distribution with given mean and standard deviation 844 845 /// Lognormal distribution with given mean and standard deviation. 846 /// 847 double lognormalMD(double mean,double std_dev) 848 { 849 return lognormal(lognormalParamsFromMD(mean,std_dev)); 823 850 } 824 851 … … 926 953 ///\name Two dimensional distributions 927 954 /// 928 929 955 ///@{ 930 956 … … 943 969 return dim2::Point<double>(V1,V2); 944 970 } 945 /// A kind of two dimensional Gaussdistribution971 /// A kind of two dimensional normal (Gauss) distribution 946 972 947 973 /// This function provides a turning symmetric twodimensional distribution.
Note: See TracChangeset
for help on using the changeset viewer.