Changes in lemon/random.h [340:0badf3bb38c2:280:e7f8647ce760] in lemon-1.2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/random.h
r340 r280 541 541 /// @{ 542 542 543 ///\name Initialization 544 /// 545 /// @{ 546 543 547 /// \brief Default constructor 544 548 /// … … 705 709 } 706 710 711 /// @} 712 713 ///\name Uniform distributions 714 /// 715 /// @{ 716 707 717 /// \brief Returns a random real number from the range [0, 1) 708 718 /// … … 761 771 return _random_bits::IntConversion<Number, Word>::convert(core); 762 772 } 773 774 /// @} 763 775 764 776 unsigned int uinteger() { … … 795 807 ///\name Non-uniform distributions 796 808 /// 809 797 810 ///@{ 798 811 799 /// \brief Returns a random bool with given probability of true result.812 /// \brief Returns a random bool 800 813 /// 801 814 /// It returns a random bool with given probability of true result. … … 804 817 } 805 818 806 /// Standard normal (Gauss)distribution807 808 /// Standard normal (Gauss)distribution.819 /// Standard Gauss distribution 820 821 /// Standard Gauss distribution. 809 822 /// \note The Cartesian form of the Box-Muller 810 823 /// transformation is used to generate a random normal distribution. … … 819 832 return std::sqrt(-2*std::log(S)/S)*V1; 820 833 } 821 /// Normal (Gauss)distribution with given mean and standard deviation822 823 /// Normal (Gauss)distribution with given mean and standard deviation.834 /// Gauss distribution with given mean and standard deviation 835 836 /// Gauss distribution with given mean and standard deviation. 824 837 /// \sa gauss() 825 838 double gauss(double mean,double std_dev) 826 839 { 827 840 return gauss()*std_dev+mean; 828 }829 830 /// Lognormal distribution831 832 /// Lognormal distribution. The parameters are the mean and the standard833 /// deviation of <tt>exp(X)</tt>.834 ///835 double lognormal(double n_mean,double n_std_dev)836 {837 return std::exp(gauss(n_mean,n_std_dev));838 }839 /// Lognormal distribution840 841 /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of842 /// the mean and the standard deviation of <tt>exp(X)</tt>.843 ///844 double lognormal(const std::pair<double,double> ¶ms)845 {846 return std::exp(gauss(params.first,params.second));847 }848 /// Compute the lognormal parameters from mean and standard deviation849 850 /// This function computes the lognormal parameters from mean and851 /// standard deviation. The return value can direcly be passed to852 /// lognormal().853 std::pair<double,double> lognormalParamsFromMD(double mean,854 double std_dev)855 {856 double fr=std_dev/mean;857 fr*=fr;858 double lg=std::log(1+fr);859 return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg));860 }861 /// Lognormal distribution with given mean and standard deviation862 863 /// Lognormal distribution with given mean and standard deviation.864 ///865 double lognormalMD(double mean,double std_dev)866 {867 return lognormal(lognormalParamsFromMD(mean,std_dev));868 841 } 869 842 … … 971 944 ///\name Two dimensional distributions 972 945 /// 946 973 947 ///@{ 974 948 … … 987 961 return dim2::Point<double>(V1,V2); 988 962 } 989 /// A kind of two dimensional normal (Gauss)distribution963 /// A kind of two dimensional Gauss distribution 990 964 991 965 /// This function provides a turning symmetric two-dimensional distribution.
Note: See TracChangeset
for help on using the changeset viewer.