http://www.lavarnd.org/news/lavadiff.html
read the left hand side if interested, i thought this was neat
read the left hand side if interested, i thought this was neat
double randomNumber() {
static long int seed = 547845897;
static long int m = 2147483647; // m is the modulus, m = 2 ^ 31 - 1
static long int a = 16807; // a is the multiplier, a = 7 ^ 5
static long int q = 127773; // q is the floor of m / a
static long int r = 2836; // r is m mod a
long int temp;
temp = a * (seed % q) - r * (seed / q);
if (temp > 0) {
seed = temp;
}
else {
seed = temp + m;
}
return (double)seed / (double)m;
}
If you don't know how they're used, then I can see how it would appear so. Most of my experience with random number generators is from simulations. The simulations we wrote were discrete event simulations; we used some know distribution to model some phenomenon, say, the arrival time of people to a lunch line. Getting a number from some known distribution requires generating a "random" number and applying the appropriate function to that number.Mental wrote:why would you want reproducible behavior if you need a random number? that's sort of a contradiction in terms isn't it?