| 844 | /// Lognormal distribution |
| 845 | |
| 846 | /// Lognormal distribution. The parameters are the mean and the standard |
| 847 | /// deviation of <tt>exp(X)</tt>. |
| 848 | /// |
| 849 | double lognormal(double n_mean,double n_std_dev) |
| 850 | { |
| 851 | return std::exp(gauss(n_mean,n_std_dev)); |
| 852 | } |
| 853 | /// Lognormal distribution |
| 854 | |
| 855 | /// Lognormal distribution. The parameter is an <tt>std::pair</tt> of |
| 856 | /// the mean and the standard deviation of <tt>exp(X)</tt>. |
| 857 | /// |
| 858 | double lognormal(const std::pair<double,double> ¶ms) |
| 859 | { |
| 860 | return std::exp(gauss(params.first,params.second)); |
| 861 | } |
| 862 | /// Compute the lognormal parameters from mean and standard deviation |
| 863 | |
| 864 | /// This function computes the lognormal parameters from mean and |
| 865 | /// standard deviation. The return value can direcly be passed to |
| 866 | /// lognormal(). |
| 867 | std::pair<double,double> lognormalParamsFromMeanStdDev(double mean, |
| 868 | double std_dev) |
| 869 | { |
| 870 | double fr=std_dev/mean; |
| 871 | fr*=fr; |
| 872 | double lg=std::log(1+fr); |
| 873 | return std::pair<double,double>(std::log(mean)-lg/2.0,std::sqrt(lg)); |
| 874 | } |
| 875 | /// Lognormal distribution with given mean and standard deviation |
| 876 | |
| 877 | /// Lognormal distribution with given mean and standard deviation. |
| 878 | /// |
| 879 | double lognormalMeanStdDev(double mean,double std_dev) |
| 880 | { |
| 881 | return lognormal(lognormalParamsFromMeanStdDev(mean,std_dev)); |
| 882 | } |
| 883 | |