Is 161803398 A 'Special' Number? Inside of Math.Random()
Solution 1:
No, but it's based on Phi (the "golden ratio").
161803398 = 1.61803398 * 10^8 ≈ φ * 10^8
More about the golden ratio here.
And a really good read for the casual mathematician here.
And I found a research paper on random number generators that agrees with this assertion. (See page 53.)
Solution 2:
This number is taken from golden ratio 1.61803398 * 10^8. Matt gave a nice answer what is this number, therefore I will just explain a little bit about an algorithm.
This is not a special number for this algorithm. The algorithm is Knuth's subtractive random number generator algorithm and the main points of it are:
- store a circular list of 56 random numbers
- initialization is process of filling the list, then randomize those values with a specific deterministic algorithm
- two indices are kept which are 31 apart
- new random number is the difference of the two values at the two indices
- store new random number in the list
The generator is based on the following recursion: Xn = (Xn-55 - Xn-24) mod m, where n ≥ 0. This is a partial case of lagged Fibonacci generator: Xn = (Xn-j @ Xn-k) mod m, where 0 < k < j and @ is any binary operation (subtraction, addition, xor).
There are several implementations of this generator. Knuth offers an implementation in FORTRAN in his book. I found the following code, with the following comment:
PARAMETER (MBIG=1000000000,MSEED=161803398,MZ=0,FAC=1.E-9)
According to Knuth, any large MBIG, and any smaller (but still large) MSEED can be substituted for the above values.
A little bit more can be found here Note, that this is not actually a research paper (as stated by Math), this is just a master degree thesis.
People in cryptography like to use irrational number (pi
, e
, sqrt(5)
) because there is a conjecture that digits of such numbers appears with equal frequency and thus have high entropy. You can find this related question on security stackexchange to learn more about such numbers. Here is a quote:
"If the constants are chosen at random, then with high probability, no attacker will be able to break it." But cryptographers, being a paranoid lot, are skeptical when someone says, "Let's use this set of constants. I picked them at random, I swear." So as a compromise, they'll use constants like, say, the binary expansion of π. While we no longer have the mathematical benefit of having chosen them at random from some large pool of numbers, we can at least be more confident there was no sabotage.