Created
September 15, 2013 00:50
-
-
Save tedtieken/6567112 to your computer and use it in GitHub Desktop.
Demonstrating that the two envelopes paradox is actually a fallacy.
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
import random | |
envs = [10.0, 20.0] | |
rounds = 10000 | |
total_stay = 0 | |
for x in xrange(rounds): | |
t_envs = envs[:] | |
random.shuffle(t_envs) | |
choice = t_envs.pop() | |
total_stay += choice | |
total_switch = 0 | |
for x in xrange(rounds): | |
t_envs = envs[:] | |
random.shuffle(t_envs) | |
choice = t_envs.pop() | |
new_choice = t_envs.pop() | |
total_switch += new_choice | |
d_rounds = rounds * 1.0 | |
print total_stay / d_rounds | |
print total_switch / d_rounds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment