Re: Does shuffle() produce uniform result ?

2007-08-28 Thread tooru honda
Thanks to everyone who replied, (and special thanks to Alex Martelli,) I was able to accomplish what I originally asked for: a shuffle() which is both fast and without bias. It is the first time I try to optimize python code, and it is definitely a very rewarding experience. To bring closure

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread tooru honda
By incorporating Alex's code, I got another performance boost of 20%. It is mostly due to Alex's more efficient implementation of block random than my own version. -tooru honda Below is the code I have now: from binascii import hexlify from os import urandom class

Re: Does shuffle() produce uniform result ?

2007-08-25 Thread tooru honda
os.urandom account for almost half of the total execution time for my program. By implementing my own random and getting a much larger chunk of random bytes from os.urandom each time, I am able to reduce the total execution time by half. -tooru honda P.S. I use python 2.5.1 on MacOSX 10.4.10

Re: Does shuffle() produce uniform result ?

2007-08-24 Thread tooru honda
number of cards is 416), the nonuniformity doesn't matter as most of you have already said. Just to avoid argument from my friend, I am considering writing my own randint and shuffle methods based on os.urandom() though. -tooru honda -- http://mail.python.org/mailman/listinfo/python-list

Does shuffle() produce uniform result ?

2007-08-24 Thread tooru honda
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 -- http

playing sound in mac osx

2007-05-01 Thread tooru honda
Hi, I am a newbie to mac and python. Is there an easy way to play wav or mp3 sound file ? I used to use winsound module before switching to mac, but that only works for windows. Thanks Tooru P.S. I am using Mac OSX 10.4.8 and Python 2.5 -- http://mail.python.org/mailman/listinfo/python-list