Statistics › Random ›
Fish Moore
Random number generator class using the Fishmann-Moore algorithm.
Controller: CodeCogs
Interface
C++
Class FishMoore
This class produces good quality random numbers using the Fishmann-Moore algorithm. It produces uniformly distributed pseudo-random 32-bit values with period of It is best suited for simulations which require random sequences of length less than 10 million. To give you an idea of the running time for each of the functions, here are the results for generating 100,000,000 random numbers on a 750MHz microprocessor :- genReal() 6 seconds
- genInt() 6 seconds
MISSING IMAGE!
1/fishmoor-378.png cannot be found in /users/1/fishmoor-378.png. Please contact the submission author.
References:
- G.S. Fishman and L.R. Moore (1986), "An exhaustive analysis of multiplicative congruential random number generators with modulus 2^31 - 1", SIAM J Sci. Stat. Comput., 7, pp. 24-45.
- The Newran03 random number generator library of Robert Davies, http://www.robertnz.net/nr03doc.htm
Example 1
- The following example displays 20 random floating point numbers and 20 random large integers.
It uses two different generators to achieve this. The first generator uses the system timer to
initialize the seed, while the second is simply initialized with a particular value.
Notice that it was necessary to divide the timer with the FMDIV value in order to
keep the seed in the (0, 1) interval. The output of the first generator will obviously vary with each execution of the program,
while the output of the second will always be the same if the seed is never changed.
#include <iostream> #include <time.h> #include <codecogs/statistics/random/fishmoore.h> using namespace std; int main() { Stats::Random::FishMoore A(time(0) / FMDIV); Stats::Random::FishMoore B(0.113); for (int i = 0; i < 20; ++i) cout << A.genReal() << endl; cout << endl; for (int i = 0; i < 20; ++i) cout << B.genInt() << endl; return 0; }
Authors
- Lucian Bentea (August 2005)
Source Code
Source code is available when you agree to a GP Licence or buy a Commercial Licence.
Not a member, then Register with CodeCogs. Already a Member, then Login.
Members of FishMoore
FishMoore
FishMoore( double s = 0.46875
)[constructor] s Default value = 0.46875
SetSeed
voidsetSeed( double s ) s Seed must be in the (0, 1) interval (endpoints are excluded).