#include <CNCL/ACG.h>
CN_ACG
CNRNG
None
CNRandom
CNACG
is the additive random number generator class.
It is a variant of a Linear Congruential Generator
(Algorithm M) described in Knuth [1]. The results undergo a permutation
controlled by a Fibonacci Additive Congruential Generator to get good
independence between samples. This is a very high quality random number
generator, although it requires a fair amount of memory for each instance
of the generator. The implementation was taken, like the MLCG, from the
GNU-library libg++.
The 'CNACG::CNACG' constructor takes two parameters: the seed and the size. The seed is any number to be used as an initial seed. The performance of the generator depends on having a distribution of bits through the seed. If you choose a number in the range of 0 to 31, a seed with more bits is chosen. Other values are deterministically modified to give a better distribution of bits. This provides a good random number generator while still allowing a sequence to be repeated given the same initial seed.
The `size' parameter determines the size of two tables used in the generator. The first table is used in the Additive Generator; see the algorithm in Knuth for more information. In general, this table is `size' longwords long. The default value, used in the algorithm in Knuth, gives a table of 220 bytes. The table size affects the period of the generators; smaller values give shorter periods and larger tables give longer periods. The smallest table size is 7 longwords, and the longest is 98 longwords. The `size' parameter also determines the size of the table used for the Linear Congruential Generator. This value is chosen implicitly based on the size of the Additive Congruential Generator table. It is two powers of two larger than the power of two that is larger than `size'. For example, if `size' is 7, the ACG table is 7 longwords and the LCG table is 128 longwords. Thus, the default size (55) requires 55 + 256 longwords, or 1244 bytes. The largest table requires 2440 bytes and the smallest table requires 100 bytes. Applications that require a large number of generators or applications that aren't so fussy about the quality of the generator may elect to use the 'CNMLCG' generator instead.
This generator has an extremly long period and provides a good independence. Unfortunately, uniformity is not too great. For further details refer to the comments included in the source 'CNACG.c'.
Constructors:
CNACG(unsigned long seed = 0, int size = 55);
CNACG(CNParam *param);
CNACG
.
In addition to the member functions required by CNCL, CNACG
provides:
virtual unsigned long as_long32();
virtual bool has_long32();
virtual void reset();
Go to the first, previous, next, last section, table of contents.