leonnnn / KnuthSRNG

An implementation of Donald E. Knuth’s “‘Super-random’ number generator”.
2 stars 0 forks source link

Donald Knuth claims cycle of 3178 #1

Open jneb opened 1 year ago

jneb commented 1 year ago

In the book by Donald Knuth, volume 2, in the introduction, page 5, I read: "With another starting number, the sequence began to repeat after 7401 values, in a cyclic period of length 3178". Now I've been calling KnuthSRNG a few million times, and I get that 98.5% of the number fall in a cycle of 4628, and the remaining 1.5% in a cycle of 2053. (I couldn't find anything else except for 6065038420.) I don't know if that's Donald's mistake, or there is a bug in this algorithm, but something seems to be wrong here. Donald, if you read this, can be more specific? If only Donald had been more specific, it would be much easier to find the problem.

jneb commented 1 year ago

I tried out all starting numbers up to 8500. Indeed, there are 8399 numbers going to the 4628 cycle, and 100 to the 2053 cycle. The exception is the most interesting: 4358 goes into a cycle of length 64.