Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2008 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/32875 to your computer and use it in GitHub Desktop.
Save anonymous/32875 to your computer and use it in GitHub Desktop.
#!/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