standarddeviationcalculator.net

Updated Free · runs in your browser

Statistics

Two envelopes paradox calculator

One envelope has twice the money of the other. Is switching worth 25% more, or nothing? Choose how the amounts are picked, then simulate thousands of games to see which strategy pays.

For the conditional analysis.

The fallacious argument and the correct one

The tempting calculation treats your amount A as fixed and the two cases as equally likely:

E[other] = ½ × 2A + ½ × A/2 = 1.25A (wrong in general)

The correct calculation averages over the way the game is set up. Let the smaller amount be X, with some distribution. Your envelope holds X or 2X with equal chance, and so does the other:

E[keep] = E[switch] = ½ E[X] + ½ E[2X] = 1.5 E[X]

After you see an amount a, the chance it is the smaller one comes from Bayes' theorem:

P(smaller | a) = P(X = a) ÷ [P(X = a) + P(X = a/2)] E[other | a] = P(smaller | a) × 2a + (1 − P(smaller | a)) × a/2

For a continuous distribution with density f, the second term uses f(a/2)/2 in place of P(X = a/2).

Worked example

The default prior makes the smaller amount a whole number from 1 to 100, all equally likely, so E[X] = 50.5 and both keeping and always switching are worth 1.5 × 50.5 = 75.75 on average.

Suppose you open your envelope and see 40. Both X = 40 and X = 20 are possible and equally likely, so P(smaller | 40) = ½ and E[other | 40] = ½ × 80 + ½ × 20 = 50. Here the 1.25A argument happens to be right: you should switch. The same holds for every amount up to 100. But any amount above 100 must be the larger envelope, and there the loss from switching is large. The best rule is to switch when you see 100 or less and keep otherwise, which is worth 94.625 on average instead of 75.75.

The simulation of 100,000 games shows the same thing: keeping and always switching both average close to 75.75, while the rule averages close to 94.6.

The powers-of-2 prior sharpens the point. With amounts 1, 2, 4, …, 1,024 for X, switching is favourable for every amount you could see except 2,048, where it costs you 1,024. Those rare, large losses exactly cancel the frequent small gains.

How to interpret the result

The 1.25A argument fails because it assumes that, whatever amount you see, the other envelope is equally likely to hold double or half. No proper probability distribution over amounts can make that true for every amount. Once a real prior is written down, the paradox disappears: switching blindly gains nothing, and switching based on the amount you see gains something only because you are using information about how the money was chosen.

Common mistakes

  • Using the same letter A for "the amount in my envelope" in both the double and half cases. In one case A is the smaller amount, in the other the larger.
  • Assuming a uniform prior over all positive amounts. No such distribution exists, and the paradox leans on pretending it does.
  • Judging from one game. Individual outcomes vary a lot; compare averages over many games.
Two envelopes paradox calculator: the worked example on this page, with its result and chart
Two envelopes paradox calculator: the worked example above, at a glance.

Common questions

What is the two envelopes paradox?

One envelope holds twice as much money as the other. You pick one at random. The argument goes: "My envelope holds A. The other holds 2A or A/2 with equal chance, so it is worth 1.25A on average. I should switch." But the same argument then says to switch back, forever. Something is wrong.

Where exactly is the mistake?

The step "2A or A/2 with probability ½ each" treats A as a fixed amount while also treating the chance of holding the smaller envelope as ½ whatever A is. Both cannot be true for every A under any proper distribution of amounts. For small amounts you are more likely to hold the smaller envelope; for large ones, the larger. Averaged over all amounts, switching gains nothing.

Should I switch after looking inside?

It depends on the amount and on how the money was chosen. If you know the distribution, switch when the expected amount in the other envelope, given what you see, is larger. The calculator shows this rule for each prior and simulates it: it beats both "always keep" and "always switch".

What if I know nothing about how the amounts were chosen?

There is still a trick, due to Thomas Cover: pick a random threshold from any distribution that covers all positive numbers, and switch only if your amount is below it. Whenever the threshold happens to land between the two amounts you make the right choice, so the strategy does strictly better than 1.5 × E[X] on average, although the edge may be small.

What is the 1.5 × E[X] figure?

If the envelopes hold X and 2X, a random envelope holds X or 2X with equal chance, so its expected value is 1.5 × E[X]. That is what both keeping and always switching are worth.