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;
349 }
while (value < 0.0);
350 value = floor(value);
351 tmp = 0.9*(1.0+factor*factor) *
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 ===");
double chisq2(void)
Returns Chi2 deviates for 2 degrees of freedom.
double m_exp_lambda
exp(-lambda)
Random number generator class definition.
std::string print(const GChatter &chatter=NORMAL) const
Print random number generator information.
double m_sqrt_lambda
sqrt(2*lambda)
unsigned long long int int64(void)
Return 64-bit random unsigned integer.
void copy_members(const GRan &ran)
Copy class members.
GRan(void)
Void constructor.
int cdf(const std::vector< double > &cdf)
Random sampling from a cumulative density function.
unsigned long long int m_value2
Value 2.
Random number generator class.
void free_members(void)
Delete class members.
double m_old_lambda
Old lambda value.
unsigned long long int m_value1
Value 1.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
GVector tan(const GVector &vector)
Computes tangens of vector elements.
unsigned long int int32(void)
Return 32-bit random unsigned integer.
unsigned long long int m_value3
Value 3.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
GRan * clone(void) const
Clone random number generator.
unsigned long long int seed(void) const
Return seed value.
double normal(void)
Returns normal deviates.
unsigned long long int m_seed
Random number generator seed.
void init_members(unsigned long long int seed=41L)
Initialise class members.
double gammln(const double &arg)
Computes logarithm of gamma function.
GRan & operator=(const GRan &ran)
Assignment operator.
virtual ~GRan(void)
Destructor.
double m_log_lambda
log(lambda)
double poisson(const double &lambda)
Returns Poisson deviates.
Exception handler interface definition.
void clear(void)
Clear random number generator.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
const int & size(void) const
Return size of vector.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Mathematical function definitions.
double exp(const double &lambda)
Returns exponential deviates.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.