Ramsey theory: the mathematical study of combinatorial objects in which a certain degree of order must occur as the scale of the object becomes large.

In other words, once a sequence becomes large enough, there’s no way to “completely” randomize it.

]]>I believe that is the http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

That algorithm is implemented in random.shuffle. Here’s how to tell:

>>> import random, inspect

>>> print inspect.getsource(random.shuffle)

it has O(n) runtime

Proof is by induction on the elements in the array in the order they are filled in. I am assuming that the randint() function outputs the integers in its range with uniform probability

Base case:

The first element can be any element in the list

Inductive Step:

Assume that the first k elements in the array are a uniformly distributed random subset of the n elements of the list. Then it is also the case that the elements from [k:n] are a uniformly distributed subset of the list. We choose one of these elements and swap it into place, so the k’th element has a uniform probability of being any element in the array

That way, you first have to prove that the random shuffler takes at least a certain estimateable value of random bits for a certain input (for an array, this will be the logarithm of the number of permutations of elements in this array) and implements a bijective mapping from a bitvector of at least this length to the permutations of elements in this array. This should be provable easily enough with an algorithm, because you mostly derive a permutation from a bitstring and a bitstring from a permutation.

If you have demonstrated this, your shuffle algorithm is essentially as random as your random source is. As others have noted, proving true randomness is impossible, and proving that things are pseudorandom with huge periods is har so using a previously implemented one is the best bet there

]]>https://github.com/rflynn/python-examples/blob/master/src/random/shuffle/icky-shuffle.py ]]>

The cause of this is almost certainly a lousy random number generator [...]This shouldn’t come as a surprise. One of the hardest parts of cryptography is random number generation. It’s really easy to write a lousy random number generator, and it’s not at all obvious that it is lousy.

http://www.schneier.com/blog/archives/2012/02/lousy_random_nu.html

]]>