Created
December 6, 2008 13:28
-
-
Save anonymous/32875 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import random | |
gates = [1,2,3] | |
n = 1000000 | |
n_switch = n_keep = 0 | |
for i in xrange(n): | |
prize = random.choice(gates) # w tej bramce jest nagroda | |
choice = random.choice(gates) # bramka wybrana przez gracza | |
empty = random.choice(list( set(gates) - set([prize,choice]) )) | |
if prize == choice: | |
n_keep += 1 | |
else: | |
n_switch += 1 | |
print 'zmiana: %f, bez zmiany: %f' % ( float(n_switch)/n, float(n_keep)/n ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment