rust-random / book

The Rust Rand Book
Other
49 stars 19 forks source link

"This is not a property of true randomness." #18

Closed vigna closed 4 years ago

vigna commented 4 years ago

This is a statement appearing in the book about equidistribution.

This is a very slippery statement. Any property of the full period is not a property of full randomness.

Say, you have a w-bit generator with w-bit output. To be "truly random", every output must be possible. OK, so your generator generates every output.

But now it is necessarily equidistributed: it generates each value exactly once along its period. if it was truly random, after O(sqrt(2^w)) outputs you should find collisions (i.e., duplicate outputs), but you won't because collisions can happen only after 2^w outputs.

You can do the same with any generator with state size kw—just look for blocks of kw bits. They must all appear (it's random, right) but then you won't find collisions at the right time.

In essence, whenever you make a statement about the full period, you can turn it into whatever you want, depending on the viewpoint.