Periods of certain lagged Fibonacci sequences

154 Views Asked by At

In Donald Knuth's The Art of Computer Programming, Vol. 2, Third Edition, exercise 3.2.2.30 states that if $f(x) = x^k + x^{k-l} - 1$, $k > 2$, $1 < l < k$ is a primitive polynomial modulo 2, then the recurrence relation $X_n = X_{n-k} - X_{n-l} \mod 2^e$, $e > 1$, has period $2^{e-1}(2^k-1)$, a desirable property if the relation is to be used for generating pseudo-random numbers (ignoring all other downsides that may make the procedure insufficient for that purpose).

For instance, $x^{55}+x^{31}-1$ is primitive, and so $(k, l) = (55, 24)$ is an example of a pair for which the conclusion holds.

Now, when implementing the recurrence relation in the .NET Framework System.Random, Microsoft accidentally used $(k, l) = (55, 34)$, and since $x^{55} + x^{21} - 1$ is not primitive, the exercise says nothing about the period of the resulting random number generator.

In the process, Microsoft made other tweaks to the algorithm which at the end of the day becomes somewhat more robust when exposed to statistical tests, but the question remains: Are there any other methods that may be applied to make deductions about the period of $X_n = X_{n-55} - X_{n-34} \mod 2^e$? And if not, is there any intuition about what makes the problem difficult?