31 #ifndef __adevs_rand_h_
32 #define __adevs_rand_h_
80 virtual void set_seed(
unsigned long seed) = 0;
105 crand(
unsigned long seed):seedp((unsigned int)seed){}
107 void set_seed(
unsigned long seed) { seedp = (
unsigned int)seed; }
111 return ((
double)
next_long()/(
double)RAND_MAX);
131 rv (
unsigned long seed = 1);
147 double triangular(
double a,
double b,
double c);
149 double uniform(
double a,
double b);
154 double normal(
double m,
double s);
162 double hyperexponential(
double p,
double a,
double b);
163 double laplace(
double a);
164 double chisquare(
unsigned int n);
165 double student(
unsigned int n);
166 double lognormal(
double a,
double b);
167 double erlang(
unsigned int n,
double a);
168 double gamma(
double a,
double b);
169 double beta(
double a,
double b);
170 double fdistribution(
unsigned int n,
unsigned int m);
171 double poisson(
double a);
172 double geometric(
double p);
173 double hypergeometric(
unsigned int m,
unsigned int n,
double p);
174 double weibull(
double a,
double b);
175 double binomial(
double p,
unsigned int n);
176 double negativebinomial(
double p,
unsigned int n);
178 int probability(
double p);
179 double lngamma(
double xx);
184 void err(errorType n);
virtual double next_dbl()=0
Get the next double uniformly distributed in [0, 1].
random_seq * copy() const
Copy the random number generator.
Definition: adevs_rand.h:116
~crand()
Destructor.
Definition: adevs_rand.h:118
rv(unsigned long seed=1)
Create a random variable with the default implementation.
Definition: adevs_rand.h:76
crand(unsigned long seed)
Create a generator with the given seed.
Definition: adevs_rand.h:105
virtual random_seq * copy() const =0
Copy the random number generator.
virtual void set_seed(unsigned long seed)=0
Set the seed for the random number generator.
Definition: adevs_rand.h:127
crand(const crand &src)
Copy constructor.
Definition: adevs_rand.h:103
double uniform(double a, double b)
Sample a uniform distribution in the range [a, b].
void set_seed(unsigned long seed)
Set the seed for the random number generator.
Definition: adevs_rand.h:107
crand()
Create a generator with the default seed.
Definition: adevs_rand.h:101
double next_dbl()
Get the next double uniformly distributed in [0, 1].
Definition: adevs_rand.h:109
double normal(double m, double s)
Definition: adevs_rand.h:97
double exponential(double a)
unsigned long next_long()
Get a raw value from the underlying random number generator.
unsigned long next_long()
Get the next unsigned long.
virtual ~random_seq()
Destructor.
Definition: adevs_rand.h:88
virtual unsigned long next_long()=0
Get the next unsigned long.
const rv & operator=(const rv &src)
Assignment operator relies on copy method of underlying stream.
void set_seed(unsigned long seed)
See the random number generator implementation.
double triangular(double a, double b, double c)