8 #ifndef RANDOM_NUMBER_GENERATORS_HPP_INCLUDED
9 #define RANDOM_NUMBER_GENERATORS_HPP_INCLUDED
46 std::uniform_real_distribution<double> uniform_01;
47 return param[1] * std::pow(1-( uniform_01(_engine) ),-1./(param[0]-1));
64 return ( ( param[0]-1 ) * param[1] ) / ( param[0]-2 );
68 return std::numeric_limits<double>::infinity();
69 std::cout <<
"First moment of power-law distribution infinite (gamma < 2)." << std::endl;
87 std::uniform_real_distribution<double> uniform_01;
88 return param[1] * std::pow(1-( uniform_01(_engine) * (1-std::pow(param[2]/param[1],(1.-param[0])))),-1./(param[0]-1));
104 return ( ( param[0]-1 ) * param[1] * ( 1 - std::pow(param[2]/param[1],2-param[0]) ) ) / ( ( param[0]-2 ) * ( 1 - std::pow(param[2]/param[1],1-param[0]) ) );
117 std::uniform_real_distribution<double> uniform_01;
118 return -param[0] * std::log(1-uniform_01(_engine));
142 double gamma_rand(std::vector<double> ¶m, std::mt19937& _engine)
144 std::uniform_real_distribution<double> uniform_01;
145 std::normal_distribution<double> normal_01(0.0,1.0);
146 double d = param[0] - 1./3.;
152 lhs = std::log( uniform_01(_engine) );
153 x = normal_01(_engine);
154 v = std::pow(1+x/(std::sqrt(9.*d)),3);
155 rhs = std::pow(x,2)/2. + d - d*v + d*std::log(v);
171 return param[0]*param[1];
180 #endif // RANDOM_NUMBER_GENERATORS_HPP_INCLUDED
double powerlaw_hardcutoff_rand(std::vector< double > ¶m, std::mt19937 &_engine)
Generates a random real number following a power-law distribution of the form with (i...
Definition: random_number_generators.hpp:85
double powerlaw_m1(std::vector< double > ¶m)
Returns the first moment of a power-law distribution of the form with .
Definition: random_number_generators.hpp:60
double powerlaw_rand(std::vector< double > ¶m, std::mt19937 &_engine)
Generates a random real number following a power-law distribution of the form with ...
Definition: random_number_generators.hpp:44
double gamma_m1(std::vector< double > param)
Returns the first moment of a gamma distribution of the form with .
Definition: random_number_generators.hpp:169
double powerlaw_hardcutoff_m1(std::vector< double > ¶m)
Returns the first moment of a power-law distribution of the form with (i.e., hard cut-off)...
Definition: random_number_generators.hpp:102
double exponential_rand(std::vector< double > ¶m, std::mt19937 &_engine)
Generates a random real number following an exponential distribution of the form with ...
Definition: random_number_generators.hpp:115
double gamma_rand(std::vector< double > ¶m, std::mt19937 &_engine)
Generates a random real number following a gamma distribution of the form with . ...
Definition: random_number_generators.hpp:142
double exponential_m1(double param)
Returns the first moment of an exponential distribution of the form with .
Definition: random_number_generators.hpp:128