# Two Envelope Problem

The Two Envelope problem is one of my favorite statistical paradoxes. It is a problem that, even after you understand it, you can still revisit and be surprised by it.

## The Two Envelope Problem

You are presented with two identical envelopes. Both of the envelopes have money in them. You are told that one envelope has some amount of money in it, and the other envelope has twice as much money in it. But you don’t know how much that amount of money is. You are allowed to choose one envelope

You choose one envelope, which you decide to call Envelope A, and open it and observe X dollars. You are now given the opportunity to switch envelopes, so you calculate the expected value of switching. Since you know one envelope has twice as much money as the other, there is a 50% chance that envelope B, has twice as much as A, and a 50% chance that envelope B has half as much as A so

B = .5 * A/2 + .5 * 2A

B = 1.25 A

You conclude that the expected value of taking envelope B is 25% greater than keeping envelope A, so you start to switch. Before you do, you realize that if you had chosen envelope B to start with, you would have done the same calculation in reverse

A = .5 * B/2 + .5 * 2B

A = 1.25 B

and determined that the expected value of envelope A was 25% greater than envelope B.

How can you resolve this apparent paradox ?

## The Fairly Nerdy Solution

There are apparently quite a few solutions out there to this problem, with their authors believing their solution is clearly correct, and others disagreeing.   I’ll leave it to you to let me know what you think of my solution.

First we need to clarify how the money was put into the envelope, because it makes a big difference to the results.   The possible options are

• Coin Flip Scenario – The money is not put into the second envelope until you look at the first envelope.   i.e. if you see \$100 in the first envelope, then the game master flips a coin to decide whether to put \$200 or \$50 in the second envelope
• Infinite Money Scenario – The money is put into both of the envelopes before you choose. One envelope has X dollars and the other envelope has 2X dollars. The game master has infinite money, and would be willing to put any amount of money, including infinite money, into the envelopes
• Finite Money Scenario – The money is put into the both of the envelopes before you choose. One envelope has X dollars and the other envelope has 2X dollars.   However the game master is only willing to put a finite amount of money in the envelope, so there would be a maximum of M dollars in any envelope

Each of those options need to be considered separately, and I think that some confusion on this problem stems from not clearly defining those options

## Coin Flip Scenario

In my opinion, this scenario doesn’t really match the problem description of having two envelopes to choose from. However it does exactly match the math description of how the expected value of the second envelope is calculated.

If you are faced with this scenario, and see X dollars in your envelope, then your expected value of switching truly is 1.25 X, because the amount of money in envelope B can be calculated by

B = .5 * X/2 + .5 * 2X = 1.25X
which is how the problem is outlined.

This is basically a double or nothing bet, but instead of nothing, it’s double or half, and it is clearly a profitable bet to take.

## Infinite Money Scenario

To my mind, this is the least realistic scenario. Because while you could set up the coin flipping problem outlined above, or set up the finite money scenario outlined below, infinite money isn’t possible.   Even if you were playing the game with the richest person alive, or even the government of all of Earth, there is still some upper limit to the total amount of money. But if you do assume infinite money, what happens?

If you are assuming infinite money, the most reasonable assumption is that one envelope has some amount of money in it, between zero to infinity dollars, and the other has half that amount in it.

The first thing we notice is that the expected value of envelope A, taken all by itself, is infinity. This is because the average of all numbers between zero to infinity is infinity.   We then immediately observe that the expected value of envelope B is also infinity.   So after solving the equation of

B = .5 * A/2 + .5 * 2A

We are left with

B = 1.25 infinity

And

A = 1.25 infinity

So this scenario doesn’t really boil down to “why is the expected value of switching greater than the expected value of not switching”   it ends up being “Infinity has weird properties that don’t match our intuition”

## Finite Money Scenario

The scenario where the envelopes have finite money is the most interesting scenario in my opinion. Both because you could actually replicate it in real life, and because the math is interesting. With the finite money scenario, the most reasonable assumption for how it gets distributed is

• The game master puts a random amount of money in the first envelope, between zero dollars up to the maximum dollars he is willing to put in one envelope, denoted as M
• The game master puts half that amount of money in the second envelope
• The game master flips a fair coin to shuffle those envelopes so they are randomly presented as envelope A & envelope B

However, we are still posed with the problem, why does

B = .5 * A/2 + .5 * 2A = 1.25 A

and

A = .5 * B/2 + .5 * 2B = 1.25 B

The cause of this apparent paradox turns out to be bad intuition on the possible distribution of money in the envelopes. The assumption in this paradox is that the all dollar amounts are equally likely. Therefore you have a 50% chance of doubling your money, and a 50% chance of cutting it in half, just like in the coin flip scenario.

For that to be true, it implies a probability function that looks like this, where all numbers are equally likely Where M is the Maximum amount of money the game master would be willing to put in a single envelope. However the actual distribution of money in those envelopes will look like this Contrary to our assumptions, all dollar amounts are not equally likely.   There will actually be 3 times as many quantities below half of the maximum value as the number above half the max value.

So before going any farther, intuitively what will this mean ?   Well clearly the likelihood of doubling our money goes down if we have a larger amount of money.   So the equation of

B = 50% * A/2 + 50% * 2A

Doesn’t really apply if the chances of getting A/2 and 2A aren’t the same for every value of A.

Why are there more small numbers than big numbers in this distribution ?   Because of the way the money is distributed.   If we ran this many times, and randomly generated the money in the first envelope to be between 0 and M dollars over and over, and then sorted that money, we would end up with a distribution that looked like this Half of our numbers are less than M/2, and half are greater than M/2. Exactly what we intuitively expect.   When we generate the numbers in the second envelope by dividing all of these by 2 we end up with all of the numbers in the second envelope being less than M/2 In total, 1/4 of the numbers in both envelopes are greater than M/2, and 3/4 less than M/2.   Note, we set up these envelopes by putting up to a maximum amount into the first envelope and then dividing to get the second envelope. The 1/4 and 3/4 distribution would still hold if you went the other way and put up to a maximum amount into the first envelope and doubled it to get the second envelope.

At this point the intuitive solution to this paradox is clear. For any number there is not an even chance that we will double the value in the envelope vs the chance that we will cut that value in half.   The chance that we will double is larger for the small values than for the large values, which will mean that the

B = 1.25 A

A = 1.25B

Equations won’t hold.

The next section works out the math for exactly what the expected value of switching is for the finite money scenario. Then, in the final section we will exploit this information to see how if we were playing this game multiple times in a row, we actually could intelligently switch and end up with more money at the end of multiple rounds than the average expected value.

## Expected Value Of Switching – Finite Money Scenario

For calculating the expected value of switching, we will give a concrete example.   For this example, we will assume that the maximum amount of money that the game master is willing to put in an envelope is \$40.

In this scenario, the average value of the lower values is \$10, and the average value of the upper values is \$30.   The average value of all the money in the envelopes is \$15, calculated by .75 * \$10 + .25 * \$30 = \$15 At this point it’s easiest to assume that we will always get either the \$10 average value, or the \$30 average value when we open an envelope.   So when we open the first envelope, 75% of the time we will get \$10, and 25% of the time we will get \$30. So what is the expected value of switching if we have either the \$30 or the \$10 in the first envelope ?   For the \$30 it’s easy because if the first envelope has money that lies in the upper half of the range, switching will always get in the lower half of the range.   So the \$30 will always be cut in half to \$15

The \$10 is interesting because for every 3 times we see the \$10, 2 of those times we will double to \$20, and 1 time we will cut in half to \$5 Breaking out the table for the expected value Finding the weighted average of 50% of \$20, 25% of \$5, and 25% of \$15 gives us the total expected value of switching envelopes, which is \$15.

So the expected value of envelope A in this case is \$15, and if we switch, the expected value of envelope B is \$15, which are the same. This resolves our paradox, since we expect the average values in these envelopes to be the same

## Exploiting This Information

Interestingly, even though the average value of A & B are the same, this is still an exploitable game assuming:

• You play more than one round and
• You can look in your envelope before deciding whether you want to switch

Our earlier calculations show that the average value of all the switches was the same as not switching. But that was just the average value. Some of the individual switches themselves were beneficial, and some lost you money. If you can find a way to distinguish the profitable switches from the unprofitable ones, you can get more money.

The obvious solution is that you want to switch when you have the low dollar amount, and not when you have the high ones. The expected value of switching when you have the low dollar is:

• You will double your money 2 times out of 3
• You will lose half your money 1 time out of 3. On average switching when your envelope has less than half the maximum amount of money the game master would be willing to put in will yield +50% on those switches. Since you likely only have a rough guess as to how much money could be in the envelopes, a good (not necessarily perfect) strategy would be to switch envelopes the first time, and then after that switch if the amount in your envelope is less than half of the running maximum you have seen.

I simulated that strategy in the Excel below, playing 1000 games with a random maximum amount of money that could be in the envelope, random amounts in one envelope, half that amount in the other, randomly shuffled.   Whatever envelope got selected (from the random shuffle) we call envelope A, and the other envelope gets call B

Implementing that strategy gave approximately 25% more money than just picking the A or B envelopes.   You can download that Excel file here. ## 7 thoughts on “Two Envelope Problem”

1. Christopher

Thank you for this analysis and discussion. I wondered about a couple of points and thought I would ask to test my understanding.

Using the let scenario of M money, is it correct that to generate a winning strategy requires information outside the problem? The two points I’m thinking about are knowing the value of M and paying multiple times.

There’s not much to say about multiple chances. The more times you get to play, the more you can implement a strategy to improve outcomes.

The M amount is critical for improved decision making. I just realized that’s a third issue not addressed in the problem statement: that you get to see what was in envelope B.C.

I suppose that this would also get into issues of risk tolerance on the part of the player.

Are these correct interpretations?
If it is a single play and the money is initially in both envelopes and not infinite money, then there it’s a fifty-fifty chance and switching has no affect on expected value?

If it’s a single play and the second envelope amount is decided by the coin toss, then it’s beneficial to always switch (somewhat related to the Monty Hall problem, in part because as you observe the downside is not a total loss)?

The player could add analysis, for example by seeing a list of the top prizes so far in the game or by making a guess about the game master about whether this is a “large” or “small”amount of money for this trial?

Are there other concepts I’m missing?

Thanks again.

1. Fairly Nerdy Post author

I would say that I agree with everything in your comment

– Risk tolerance on the part of the player is a whole separate issue that I’m sure could be covered in great detail.

– I would agree that if you are playing this in real life (i.e. finite money), and you have no outside information about that Maximum money in the envelope then there is no value to be gained by switching. If you can gain some information through outside analysis (guessing “large” or “small”, seeing top prizes, playing multiple times) you can implement a better than random strategy

– For the single play scenario where the amount in the second envelope is decided by a coin flip, it is definitely beneficial to switch. I think of this somewhat like setting up options in stock market investing so that if you win you win a lot of money, and if you lose you lose a little bit

– The only part I don’t really have a complete grasp on is the infinite money scenario. I think that for instance infinity plus infinity, which equals 2 infinity, is also equal to infinity. Therefore in our analysis when we show that A = infinity and B = infinity and that A = 1.25 B, we are really just saying infinity = infinity. But infinities do have some weird properties, and I know some infinities are larger than other infinities, that I don’t fully understand

2. JeffJo

1A) Money always comes in discrete increments. Whether that increment is one dollar, one cent, one pound, one euro, one yen, or one “whatever,” odd multiples of that increment must be the lower value. 1B) So if A=2N+1 “whatevers,” then B=A/2 “whatevers” is obviously an impossibility.
1C) If A=4N+2, A=2N+1 must have been a possibility as well, leading to the same conclusion.
1D) The original premise Pr(B=A/2)=Pr(B=2A)=1/2 cannot be true in general if it comes in discrete values.

2A) If continuous values are allowed (and note that discrete can be modeled as a special case of continuous), the assumption that B is equally likely to be A/2 or 2A requires that, for any X, Pr(X/2<=A<X) = Pr(X<=A<2X). I'm skipping the derivation, but it isn't too hard to show once you realize that the distributions of A and B have to be the same, and that Pr(X/2<=A<=X) has to be [Pr(X/4<=B<=X/2)+Pr(X<=B<=2X)]/2.
2B) The only solution for a such a distribution is Pr(X<=A<2X)=0 for all X, which isn't a probability distribution at all.

The error in the supposedly paradoxical solution, is that assuming anything specific about the random variable A – such as its value – requires you to use conditional probability.

1. Fairly Nerdy Post author

Jeff,

I have to disagree with you that money in the game can only be discrete amounts. You & I can agree to play the game using a continuous distribution created by a random number generator, and then just say that whatever money you end up winning we will round to the nearest penny when I payout.

For references on that topic, I refer you to office space
https://youtu.be/GlRG9x0JRMc?t=131

and superman III

Per point 2, I completely agree with you that a equal probability distribution between the amount vs double the amount is impossible

3. JeffJo

Well, I’ll challenge you to find a monetary system that doesn’t. 🙂 Even your suggestion is really using the phoney, but continuous, range N+U(-0.5,0.5) to represent the true, but discrete, value N. But I used that as the *preliminary* example because it was easier to work with, and established the fundamentals for how the continuous case would work in point #2.

And your suggestion, for using a random number generator, won’t work. Any RNG has to have finite lower- and upper-bounds. The lower bound is easy: zero. I used it in point #1 because it was easy. But the upper bound you’d need to implement your suggestion is infinity, and there can be no such RNG.

The point I hoped you’d come away with, is that the paradoxical solution is being treated as an unconditional probability, when it really is a conditional one. This is the error made in most probability paradoxes. You can get the correct answer, but only if you first establish that all of the possibilities the condition could have are uniformly distributed.

For example, using a single value X here is incorrect, since you’d have to establish that X/2 and 2X have the same (prior) probability. But if your random variable is, say, the total amount in the two envelopes T, then the condition is whether you picked the smaller amount T/3, or the larger amount 2T/2, which is uniformly distributed. And the expects gain by switching is zero.

1. JeffJo

Argggh! I hate typos. That was T/3 or 2T/3.

2. Fairly Nerdy Post author

I think you mean 2T/3 in your last sentence. Which clearly invalidates the rest of the post. 🙂

Haha, no but seriously I feel like we’re agreeing on most points. The apparent paradox is based on the incorrect assumption of an even probability distribution, when it cannot be.

I will agree that your comments may have summarized that point it more succinctly, but my post has prettier pictures 🙂