W
Walter Banks
Keith said:[...]Walter Banks said:I did some work on random numbers used in a Monte Carlo
simulator. The one thing to remember is, "A random number
generator will try very hard to not be random".
Can you expand on that? I'm having trouble thinking of an
interpretation of that last statement that makes sense.
What am I missing?
I know several people that for various reasons have wanted
to modify a random number by limiting to a range or a
particular distribution. Most attempts to do that as Kaz's
earlier comment on modulus pointed out has un intended
side effects that seriously disturbs the resulting expectation.
The same thing has been observed by most people trying to
implement random number generators with specific outputs.
It is someone else's quote but I have forgotten who should be
credited.
BTW range is just one specific case of random numbers
with specific distributions.
What we did to create a random number for a range in the MC
simulator was first create a dependable random number generator
with a distribution from 0..1 and then for a range used
range(n,m) = n + ((m-n) * rand0_1);
A random number with a distribution of 0..1 can be a linear
integer random number but treated like a fractional number.
Do a integer multiply of (m-n) by the random number and
discard the least significant bits equal to the fraction width.
There are a number of easy ways that this can be done in C
to avoid any floating point operations. (double the width of the
int for the multiply or do a fixed point fract by int multiply)
w..