The two envelope problem is a famous problem from decision theory, at least famous enough to have its own Wikipedia page. It’s an interesting problem, but this post is about its less well known variation.

Here is the formulation.

There are two envelopes, one with and one with dollars, . and are unknown positive integers. You are randomly given an envelope, can look inside, then must choose whether to switch envelopes or not.

Does there exists a switching strategy which ends with the larger envelope more than half the time?

At first glance, the answer should be no. Although we know the contents of one envelope, we have no information on how much the other envelope might have. When the other envelope is a black box, how can we make a meaningful decision?

As it turns out, such a strategy does exist, and the small amount of information we have (the amount in the current envelope) is enough to improve our standing, even when the alternative has unknown value.

The Power of Randomness

The trick is to make the switching decision randomly, in a way that biases outcomes to end with the larger envelope. The strategy is as follows:

  • Inspect amount inside the envelope.
  • Flip a fair coin until it lands tails.
  • If there were at least flips, switch envelopes. Otherwise, do not switch.

For analysis, assume without loss of generality that . There are two ways to end with envelope . Either start with and switch, or start with and do not switch. The first case happens with probability

The second happens with probability

So, the chance to end with is

which is indeed larger than for .

Extending to the Reals

This coin flip strategy works when and are integers, but fails when are arbitrary reals. The problem is that the number of flips comes from a discrete distribution, so it does not have the granularity to distinguish between values like .

So, how is this strategy extendable? The way the current strategy works is by creating a decision boundary based on the amount in the seen envelope. The boundary is then applied to the geometric distribution with parameter .

Geometric pmf with decision boundary

Decision boundaries when . The switching strategy gets an advantage when the sampled lies between the two boundaries.

To handle arbitrary reals, we should use a continuous probability distribution instead. Nothing in the previous logic relies on the distribution being discrete, so we can simply drop in a distribution of our choice. The only requirement we need is a strictly positive probability density function over (we’ll explain why we need this later.) The standard normal distribution will do fine.

The modified strategy is

  • Inspect amount inside the envelope.
  • Sample from .
  • If . switch. Otherwise, do not switch.

Normal pdf with decision boundary

Decision boundaries when . Again, the switching strategy gets an advantage when falls between and .

The proof is also similar. For , . This is why the p.d.f. needs to be positive everywhere. If the p.d.f. is zero over some interval , it is possible that both , which gives . The chance of ending with the larger envelope is

and this strategy generalizes to real valued envelopes.

Extending to Multiple Envelopes

At this point, it’s worth considering whether we can take any lessons from this problem. If we substitute “given an envelope” with “given an action”, and “dollars” with “utility”, this result suggests that even with no information on alternative choices, we could use a random action to improve our current standing. In real life, we often have very little information on how different actions will play out, so this power to bias towards improvement is appealing. However, in real life there are usually much more than two possible actions, so we should first consider whether the two envelope framework is even valid.

When there are envelopes instead of envelopes, we can no longer aim for only the best envelope. The switch could slightly help us, slightly hurt us, especially help us, or especially hurt us. Because of this, we need to modify the criteria of a good strategy.

There are envelopes, which give utilities . The are unknown real numbers. You are randomly given an envelope, can look inside, then must choose whether to switch with another envelope.

Does there exist a switching strategy that improves your utility more often than it worsens your utility?

Once again, it turns out the real valued two envelope strategy still works with appropriate modifications. We still choose whether to swap by seeing if sample is greater than seen utility . The only difference is choosing which envelope to switch to. From the opener’s perspective, every other envelope appears identical. Thus, if the strategy says to swap, we should pick an alternative envelope at random.

This leaves showing the improvement chance is higher than the worsening chance. If the algorithm does not swap, the utility is unchanged, so it suffices to analyze only situations where we switch envelopes.

For envelope , the chance of switching is . The reward rises for envelopes and drops for envelopes. Thus, the chance of improving utility is

and the chance of worsening utility is

Envelope has envelopes that are better, and envelope has envelopes that are worse. Intuitively, every improving term for should cancel with a worsening term for , but the improving terms have more weight because the switching probability after observing is higher. This is formalized below.

Take the difference and pair up terms with matching to get

The coefficients of the terms are . Since we only care about whether the difference is positive, multiply by to get two copies of the terms, then pair terms by coefficient, matching each coefficient with its negative.

Consider each term of this summation.

  • For , the coefficient is positive, and , so is positive. The entire term is positive.
  • For , the coefficent is .
  • For , the coefficient is negative, and , so is negative. The entire term is positive.

Every term in the summation is positive or zero, so the entire sum is positive, and the probability of increasing utility is higher than the probability of decreasing it.

Implications

So, now we have a strategy that is very slightly biased towards increasing utility. But before trying to implement this in real life, it’s worth thinking through all the complications.

  • The values are chosen through some unknown process. Although this strategy is more likely to end on a larger , it is impossible to quantify how much better your utility will be after the swap. The utility might even go down in expectation. Although the chance of improving utility is higher, the potential utility increase may be small while the potential utility decrease is large. If we had more information about how are generated, then we could argue this in more detail, but at that point this information independent scheme is probably no longer useful.
  • The analysis relies on having a value on the initial action. It is incredibly likely that we are just as confused about the value of our current action as we are about the values of other actions, which renders the strategy moot.
  • The analysis also relies on starting with an action picked uniformly at random out of a pool of possible actions. In reality, this is almost never the case. We usually have reasons to choose to act in one way or another, which places a non-uniform prior on the initial action. Intuitively, if we are already good at making decisions, it is far less likely we can switch to an even better one.

So overall, this is not a life hack. All we have is a surprising decision theory result, and that’s fine too.

(Thanks to the people who helped review earlier drafts.)