#include <copy-ocsRanNumGen.hh>
Public Methods | |
RanNumGen (string InFileName) | |
Class constructor. More... | |
~RanNumGen () | |
Class destructor. More... | |
void | SaveCurrentState (void) |
Saves the current state of the random number generator. More... | |
void | ResetRanNumGen (void) |
Resets the RNG to the state it was in at the beginning of the job or that was saved by a call to RanNumGen::SaveCurrentState. | |
float | GetRanNum (void) |
Returns the next random number in the sequence. More... | |
float | GetRanCosineBiased (double alpha, double beta, double *LikelihoodRatio) |
This method generates a biased sample for importance sampling. | |
float | GetRanSignBiased (double alpha, double *LikelihoodRatio) |
float | GetRanCosineBiased (double alpha, double *LikelihoodRatio) |
float | GetGaussianDeviate (void) |
Returns a random sample from a the 1-dimensaional Gaussian distribution with mean 0 and standard deviation 1. More... | |
void | ReadRanSeqParameters (string InFileName) |
Initializes the state of the RNG by reading the state parameters from a file. | |
void | WriteRanSeqParameters (string OutFileName) |
Writes the current state of the RNG to a file. More... | |
Private Attributes | |
long | idum |
long | idumStart |
long | idum2 |
long | idum2Start |
long | iy |
long | iyStart |
long | iv [NTAB] |
long | ivStart [NTAB] |
string | ContinuationFileName |
The name of the file to which the current state of the RNG is written. | |
string | RestartFileName |
The name of the file to which the state of the RNG at the start of the current job is written. | |
Static Private Attributes | |
const long | IM1 = 2147483563 |
const long | IM2 = 2147483399 |
const double | AM = 1.0/2147483563 |
const long | IMM1 = IM1 - 1 |
const long | IA1 = 40014 |
const long | IA2 = 40692 |
const long | IQ1 = 53668 |
const long | IQ2 = 52774 |
const long | IR1 = 12211 |
const long | IR2 = 3791 |
const int | NTAB = 32 |
const long | NDIV = (1+IMM1/NTAB) |
const double | EPS = 1.2e-7 |
const double | RNMX = 1.0-EPS |
The RanNumGen class uses the Random Number Generator (RNG) ran2 from Numerical Recipes in C. A helpful discussion of this random number generator can be found in the book Numerical Recipes in C or online at http://www.nr.com/ . Additional discussion can be found in "Random Number Generation and Monte Carlo Methods" by James E. Gentle (Springer).
The class contains methods that read and write the state of the RNG from and to a file. When running multiple jobs this feature enables the user to either continue along the random sequence from where we left off at the end of the last job or restart the RNG at the point in the sequence where the previous job started. The RNG can also be restarted within a job.
The class also contains methods that are used in importance sampling.
|
Class constructor. The constructor reads parameters from an input parameter file.
|
|
Class destructor. Calls the method void WriteRanSeqParameters(string OutFileName) which writes the final state of the RNG to a file. Hence it should be explicitly called in application programs!
|
|
Returns a random sample from a the 1-dimensaional Gaussian distribution with mean 0 and standard deviation 1. This code was taken directly from Numerical Recipes in C. See http://www.nr.com/ for documention. |
|
The method returns a float which is the value of the biased sample.
|
|
This method generates a biased sample for importance sampling.
|
|
Returns the next random number in the sequence. This code was taken directly from Numerical Recipes in C, function ran2.\n See http://www.nr.com/ for documention. |
|
|
|
Initializes the state of the RNG by reading the state parameters from a file.
|
|
Resets the RNG to the state it was in at the beginning of the job or that was saved by a call to RanNumGen::SaveCurrentState.
|
|
Saves the current state of the random number generator. Should be used in conjunction with RanNumGen::ResetRanNumGen |
|
Writes the current state of the RNG to a file.
|
|
|
|
The name of the file to which the current state of the RNG is written.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The name of the file to which the state of the RNG at the start of the current job is written.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|