38 m_ = 1024 * 1024 * 1024;
73 os <<
" " <<
static_cast<unsigned int>(
type_);
137 for (
unsigned int i = 0; i <
p_; i++)
151 for (
unsigned int i = 0; i <
p_ - 1; i++)
162 random_num = min + range * new_seed;
175 static unsigned int num_of_tests = 100000;
176 static Mdouble max_num = 100.0;
177 static unsigned int num_of_bins = 10;
182 unsigned int bin = 0;
184 std::vector<int> count;
185 count.resize(num_of_bins);
188 for (
unsigned int i = 0; i < num_of_bins; i++)
194 for (
unsigned int i = 0; i < num_of_tests; i++)
197 bin =
static_cast<unsigned int>(std::floor(rn * num_of_bins / max_num));
206 Mdouble expected = num_of_tests / num_of_bins;
208 for (
unsigned int i = 0; i < num_of_bins; i++)
210 chi_cum = chi_cum + (count[i] - expected) * (count[i] - expected) / expected;
211 std::cout << i <<
" : " << count[i] <<
" : " << (count[i] - expected) * (count[i] - expected) / expected << std::endl;
214 std::cout << chi_cum << std::endl;
void read(std::istream &is)
Mdouble chi_squared_prob(const Mdouble x, const unsigned int k)
This is the function which actually gives the probability back using a chi squared test...
Mdouble getRandomNumberFromLaggedFibonacciGenerator(Mdouble min, Mdouble max)
This is a Lagged Fibonacci Generator.
void seedLaggedFibonacciGenerator()
This seed the LFG.
void setLaggedFibonacciGeneratorParameters(const unsigned int p, const unsigned int q)
This function sets the parameters for the LFG random number generator.
void randomise()
sets the random variables such that they differ for each run
void setLinearCongruentialGeneratorParmeters(unsigned const int a, unsigned const int c, unsigned const int m)
This functions set the parameters for the LCG random number generator. It goes multiplier, addition, mod.
void write(std::ostream &os) const
Mdouble getRandomNumberFromLinearCongruentialGenerator(Mdouble min, Mdouble max)
This is a basic Linear Congruential Generator Random.
unsigned long int randomSeedLinearCongruentialGenerator_
This is the initial seed of the RNG.
unsigned long int p_
This are the parameters that control the LFG random generator.
void setRandomSeed(unsigned long int new_seed)
This is the seed for the random number generator. (note the call to seed_LFG is only required really ...
Mdouble test()
This function tests the quality of random numbers, based on the chi-squared test. ...
std::vector< Mdouble > randomSeedLaggedFibonacciGenerator_
This is the seeds required for the LFG.
unsigned long int a_
This are the two parameters that control the LCG random generated.
void setRandomNumberGenerator(RNGType type)
Allows the user to set which random number generator is used.
RNGType type_
This is the type of random number generator.
Mdouble getRandomNumber(Mdouble min, Mdouble max)
This is a random generating routine can be used for initial positions.