Does shuffle() produce uniform result ?

tooru honda tooru_honda at fast-mail.org
Fri Aug 24 03:38:51 EDT 2007


Hi,

I have read the source code of the built-in random module, random.py.  
After also reading Wiki article on Knuth Shuffle algorithm, I wonder if 
the shuffle method implemented in random.py produces results with modulo 
bias.

The reasoning is as follows: Because the method random() only produces 
finitely many possible results, we get modulo bias when the number of 
possible results is not divisible by the size of the shuffled list.

1. Does shuffle() produce uniform result ?

2. If not, is there a fast and uniform shuffle() available somewhere ?

Thanks !

-tooru honda



More information about the Python-list mailing list