Changeset 2483:bf6d7b624d5c in lemon0.x
 Timestamp:
 10/01/07 20:57:21 (12 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@3322
 Files:

 1 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

lemon/random.h
r2391 r2483 749 749 } 750 750 751 double gamma(int k) 752 { 753 double s = 0; 754 for(int i=0;i<k;i++) s=std::log(1.0real<double>()); 755 return s; 756 } 757 758 /// Gamma distribution with given shape and scale parameter 759 760 /// This function generates a gamma distribution random number. 761 /// 762 ///\param k shape parameter (<tt>k>0</tt>) 763 ///\param theta scale parameter 764 /// 765 double gamma(double k,double theta=1.0) 766 { 767 double xi,nu; 768 const double delta = kstd::floor(k); 769 const double v0=M_E/(M_Edelta); 770 do { 771 double V0=1.0real<double>(); 772 double V1=1.0real<double>(); 773 double V2=1.0real<double>(); 774 if(V2<=v0) 775 { 776 xi=std::pow(V1,1.0/delta); 777 nu=V0*std::pow(xi,delta1.0); 778 } 779 else 780 { 781 xi=1.0std::log(V1); 782 nu=V0*std::exp(xi); 783 } 784 } while(nu>std::pow(xi,delta1.0)*std::exp(xi)); 785 return theta*(xigamma(int(std::floor(k)))); 786 } 787 788 751 789 ///@} 752 790 
test/Makefile.am
r2363 r2483 37 37 test/radix_sort_test \ 38 38 test/refptr_test \ 39 test/random_test \ 39 40 test/simann_test \ 40 41 test/suurballe_test \ … … 85 86 test_radix_sort_test_SOURCES = test/radix_sort_test.cc 86 87 test_refptr_test_SOURCES = test/refptr_test.cc 88 test_random_test_SOURCES = test/random_test.cc 87 89 test_simann_test_SOURCES = test/simann_test.cc 88 90 test_suurballe_test_SOURCES = test/suurballe_test.cc
Note: See TracChangeset
for help on using the changeset viewer.