Discrete Distributions¶
|
API
|
Classes | |
| class | cIntUniform |
| Generates random numbers from the discrete uniform distribution. More... | |
| class | cIntUniformExcl |
| Generates random numbers from the discrete uniform distribution. More... | |
| class | cBernoulli |
| Generates random numbers that are the results of Bernoulli trials. More... | |
| class | cBinomial |
| Generates random numbers from the binomial distribution. More... | |
| class | cGeometric |
| Generates random numbers from the geometric distribution. More... | |
| class | cNegBinomial |
| Generates random numbers from the negative binomial distribution. More... | |
| class | cPoisson |
| Generates random numbers from the Poisson distribution. More... | |
Functions | |
| SIM_API int | intuniform (cRNG *rng, int a, int b) |
| Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b.) | |
| SIM_API int | intuniformexcl (cRNG *rng, int a, int b) |
| Returns a random integer with uniform distribution over [a,b), that is, from [a,b-1]. | |
| int | bernoulli (cRNG *rng, double p) |
| Returns the result of a Bernoulli trial with probability p, that is, 1 with probability p and 0 with probability (1-p). | |
| SIM_API int | binomial (cRNG *rng, int n, double p) |
| Returns a random integer from the binomial distribution with parameters n and p, that is, the number of successes in n independent trials with probability p. | |
| SIM_API int | geometric (cRNG *rng, double p) |
| Returns a random integer from the geometric distribution with parameter p, that is, the number of independent trials with probability p until the first success. | |
| SIM_API int | negbinomial (cRNG *rng, int n, double p) |
| Returns a random integer from the negative binomial distribution with parameters n and p, that is, the number of failures occurring before n successes in independent trials with probability p of success. | |
| SIM_API int | poisson (cRNG *rng, double lambda) |
| Returns a random integer from the Poisson distribution with parameter lambda, that is, the number of arrivals over unit time where the time between successive arrivals follow exponential distribution with parameter lambda. | |
Description
Random variate generators for discrete distributions.
Function Documentation
◆ intuniform()
| SIM_API int intuniform | ( | cRNG * | rng, |
| int | a, | ||
| int | b ) |
Returns a random integer with uniform distribution in the range [a,b], inclusive. (Note that the function can also return b.)
- Parameters
-
a,b the interval, a<=b rng the underlying random number generator
Referenced by cComponent::intuniform().
◆ intuniformexcl()
| SIM_API int intuniformexcl | ( | cRNG * | rng, |
| int | a, | ||
| int | b ) |
Returns a random integer with uniform distribution over [a,b), that is, from [a,b-1].
- Parameters
-
a,b the interval, a<b rng the underlying random number generator
Referenced by cComponent::intuniformexcl().
◆ bernoulli()
|
inline |
Returns the result of a Bernoulli trial with probability p, that is, 1 with probability p and 0 with probability (1-p).
Generation is using elementary look-up.
- Parameters
-
p 0=<p<=1 rng the underlying random number generator
References cRNG::doubleRand().
Referenced by cComponent::bernoulli().
◆ binomial()
| SIM_API int binomial | ( | cRNG * | rng, |
| int | n, | ||
| double | p ) |
Returns a random integer from the binomial distribution with parameters n and p, that is, the number of successes in n independent trials with probability p.
Generation is using the relationship to Bernoulli distribution (runtime is proportional to n).
- Parameters
-
n n>=0 p 0<=p<=1 rng the underlying random number generator
Referenced by cComponent::binomial().
◆ geometric()
| SIM_API int geometric | ( | cRNG * | rng, |
| double | p ) |
Returns a random integer from the geometric distribution with parameter p, that is, the number of independent trials with probability p until the first success.
This is the n=1 special case of the negative binomial distribution.
Generation uses inverse transform.
- Parameters
-
p 0<p<=1 rng the underlying random number generator
Referenced by cComponent::geometric().
◆ negbinomial()
| SIM_API int negbinomial | ( | cRNG * | rng, |
| int | n, | ||
| double | p ) |
Returns a random integer from the negative binomial distribution with parameters n and p, that is, the number of failures occurring before n successes in independent trials with probability p of success.
Generation is using the relationship to geometric distribution (runtime is proportional to n).
- Parameters
-
n n>=0 p 0<p<1 rng the underlying random number generator
Referenced by cComponent::negbinomial().
◆ poisson()
| SIM_API int poisson | ( | cRNG * | rng, |
| double | lambda ) |
Returns a random integer from the Poisson distribution with parameter lambda, that is, the number of arrivals over unit time where the time between successive arrivals follow exponential distribution with parameter lambda.
Lambda is also the mean (and variance) of the distribution.
Generation method depends on value of lambda:
- 0<lambda<=30: count number of events
- lambda>30: Acceptance-Rejection due to Atkinson (see Banks, page 166)
- Parameters
-
lambda > 0 rng the underlying random number generator
Referenced by cComponent::poisson().
Generated on for API by