Random Sample
Generates random numbers following a Poisson distribution.
Controller: CodeCogs
Dependents
Interface
C++
Class RandomSample
The Poisson distribution is used to model the number of events occurring within a given time interval. The formula for the Poisson probability mass function, which we also use with this random number generator is where is the shape parameter indicating the average number of events in the given time interval. Using this class, the diagram below is generated from two distinct sequences of 1000 random numbers. Each pair of numbers are plotted against each other, to illustrate the Poisson behaviour of this non-uniform random number generator.MISSING IMAGE!
1/poisson.png cannot be found in /users/1/poisson.png. Please contact the submission author.
Speed
The average running time for generating 100,000,000 random numbers using this class on a 750MHz microprocessor is 56 seconds.Example 1
#include <iostream> #include <time.h> #include <codecogs/statistics/distributions/discrete/poisson/randomsample.h> int main() { Stats::Dists::Discrete::Poisson::RandomSample A(53.29, 0.15); Stats::Dists::Discrete::Poisson::RandomSample B(61.47, time(0) / MERSENNEDIV); for (int i = 0; i < 20; ++i) std::cout << A.genInt() << " "; std::cout << std::endl << std::endl; for (int i = 0; i < 20; ++i) std::cout << B.genInt() << " "; std::cout << std::endl; return 0; }
Output:51 60 51 68 50 50 45 61 58 49 55 38 48 58 52 60 52 48 48 48
References
- NIST/SEMATECH e-Handbook of Statistical Methods, http://www.itl.nist.gov/div898/handbook/
- The Newran03 random number generator library of Robert Davies, http://www.robertnz.net/nr03doc.htm
Authors
- Lucian Bentea (June 2005)
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
Members of RandomSample
RandomSample
Constructor that sets up the class variables and initializes the associated random number generator with the given seed.RandomSample( double mu double seed = 0.8476
)[constructor] seed Default value = 0.8476
Sample
intsample( | double | mu | |
double | seed = 0.123 | ) |
#include <time.h> ... sample(mu, time(0) / MERSENNEDIV);If you require more advance behaviour, we strongly recommend using the underlying class randomsample (above).
Parameters
mu average number of events seed sets the initial seed for the random generator. Only used in the first call to this function
Source Code
Source code is available when you buy a Commercial licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.