178 return new GRan(*
this);
209 return ((
unsigned long int)
int64());
245 return (5.42101086242752217e-20 *
int64());
264 double x2 = 2.0 *
uniform() - 1.0;
265 w = x1 * x1 + x2 * x2;
269 double value = x1 * std::sqrt((-2.0 * std::log(w)) / w);
302 return (-std::log(x)/lambda);
349 }
while (value < 0.0);
350 value = floor(value);
351 tmp = 0.9*(1.0+factor*factor) *
381 return (std::sqrt(-2.0*std::log(1.0-x)));
398 int high =
cdf.size();
399 while ((high - low) > 1) {
400 int mid = (low+high) / 2;
404 else if (
cdf[mid] <= u) {
429 int high =
cdf.size();
430 while ((high - low) > 1) {
431 int mid = (low+high) / 2;
435 else if (
cdf[mid] <= u) {
460 result.append(
"=== GRan ===");
Exception handler interface definition.
Mathematical function definitions.
Random number generator class definition.
Random number generator class.
GRan * clone(void) const
Clone random number generator.
unsigned long long int int64(void)
Return 64-bit random unsigned integer.
double m_sqrt_lambda
sqrt(2*lambda)
unsigned long long int m_value1
Value 1.
unsigned long long int seed(void) const
Return seed value.
double normal(void)
Returns normal deviates.
std::string print(const GChatter &chatter=NORMAL) const
Print random number generator information.
unsigned long long int m_value2
Value 2.
double m_log_lambda
log(lambda)
unsigned long int int32(void)
Return 32-bit random unsigned integer.
double chisq2(void)
Returns Chi2 deviates for 2 degrees of freedom.
void clear(void)
Clear random number generator.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void free_members(void)
Delete class members.
unsigned long long int m_seed
Random number generator seed.
GRan(void)
Void constructor.
int cdf(const std::vector< double > &cdf)
Random sampling from a cumulative density function.
void init_members(unsigned long long int seed=41L)
Initialise class members.
double exp(const double &lambda)
Returns exponential deviates.
unsigned long long int m_value3
Value 3.
void copy_members(const GRan &ran)
Copy class members.
GRan & operator=(const GRan &ran)
Assignment operator.
double m_exp_lambda
exp(-lambda)
double poisson(const double &lambda)
Returns Poisson deviates.
virtual ~GRan(void)
Destructor.
double m_old_lambda
Old lambda value.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double gammln(const double &arg)
Computes logarithm of gamma function.