WichHill
Random number generator class using the Wichmann-Hill algorithm.
Interface
#include <codecogs/statistics/random/wichhill.h>
using namespace Statistics::Random;
Overview
This class produces very good quality random numbers using the Wichmann-Hill algorithm. It produces uniformly distributed pseudo-random 32-bit values with period of
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 18 seconds
- genInt 44 seconds

This diagram is obtained by generating two sequences of 1000 uniform floating point random numbers in the (0, 1) interval and then plotting them one versus the other. It shows that the distribution is indeed uniform.
References
- B.A. Wichmann and I. D. Hill (1982). Algorithm AS 183: "An Efficient and Portable Pseudo-random Number Generator", Applied Statistics, 31, 188-190; Remarks: 34,p.198 and 35, p.89.
- The Newran03 random number generator library of Robert Davies, http://www.robertnz.net/nr03doc.htm
Example 1
The following example displays 20 random large integers. Obviously the output will always be the same as the seed of the generator A never changes.
#include <iostream>
#include <codecogs/statistics/random/wichhill.h>
int main() {
Stats::Random::WichHill A(0.146);
for (int i = 0; i < 20; ++i)
std::cout << A.genInt() << std::endl;
return 0;
}Members of WichHill
CLASS METHOD
WichHill
Parameters
CLASS METHOD
WichHill
CLASS METHOD
genReal
//! Generates an uniform floating point number in the (0, 1) interval (endpoints are excluded). /*!
CLASS METHOD
genInt
CLASS METHOD
setSeed
Parameters
CLASS METHOD