Introduction

Two sealed envelopes sit on a table. You are told that one contains exactly twice as much money as the other — but you don't know which is which. You pick one at random and peek inside: it holds $100.

Now a voice offers you a choice: keep it, or swap for the other envelope. Most people shrug and say it doesn't matter. But a slick expected-value argument says it always matters — and you should always swap:

"The other envelope holds either $50 (with probability 1/2) or $200 (with probability 1/2). The expected value of swapping is \frac{1}{2} \cdot 50 + \frac{1}{2} \cdot 200 = \125$, which is more than the $100 you hold. Always switch."

So you swap. You now hold the other envelope. The same argument applies again — and again — for ever. You are trapped in an infinite loop of swapping, and nothing in the math seems to stop you.

This is the Two Envelopes Paradox, an open puzzle in probability and decision theory. Its resolution is subtle: the naive argument smuggles in a hidden assumption about the distribution of amounts that cannot actually hold.

Try It

The demo below lets you choose a prior distribution over the smaller envelope amount. For each prior, it computes the true expected gain from switching after observing xx in your envelope.

<!-- Two Envelopes Paradox demo: choose a prior, observe the gain from switching -->
<div class="controls">
  <label for="prior-select">Prior distribution over amounts:</label>
  <select id="prior-select">
    <option value="uniform">Uniform on [$1, $50]</option>
    <option value="geometric" selected>Geometric (powers of 2)</option>
    <option value="exponential">Exponential (λ = 0.05)</option>
  </select>
  <label for="x-range" id="x-label">Your envelope contains: $ <span id="x-val">10</span></label>
  <input type="range" id="x-range" min="1" max="100" value="10" step="1">
</div>
<div class="result-box" id="result-box">
  <div class="result-row">
    <span class="result-label">Your envelope ($x)</span>
    <span class="result-value" id="val-x">$10</span>
  </div>
  <div class="result-row">
    <span class="result-label">P(other = 2x | x)</span>
    <span class="result-value" id="val-pa">—</span>
  </div>
  <div class="result-row">
    <span class="result-label">P(other = x/2 | x)</span>
    <span class="result-value" id="val-pb">—</span>
  </div>
  <div class="result-row">
    <span class="result-label">E[other | x]</span>
    <span class="result-value" id="val-ev">—</span>
  </div>
  <div class="result-row highlight">
    <span class="result-label">Expected gain from switching</span>
    <span class="result-value" id="val-gain">—</span>
  </div>
</div>
<div class="verdict" id="verdict"></div>
<div class="explanation" id="explanation"></div>
<button id="btn-naive" type="button">Show the naive argument</button>
<div class="naive-box hidden" id="naive-box">
  <strong>The naive argument (flawed):</strong>
  <p>E[other] = ½ · (x/2) + ½ · (2x) = 5x/4. Since 5x/4 > x, always switch. Then apply the same logic to the new envelope — and switch again, forever.</p>
  <p class="naive-warn">This assumes P(other = 2x) = P(other = x/2) = ½ regardless of x, which implies an improper flat prior over all positive reals — not a valid distribution.</p>
</div>
/* Styles for the Two Envelopes demo panel */
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; margin: 0; color: #222; }
.controls { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
label { font-size: .85rem; color: #555; font-weight: 600; }
select, input[type=range] { width: 100%; }
select { padding: .3rem .4rem; border: 1px solid #ccc; border-radius: 6px; font-size: .9rem; }
.result-box { background: #f0f4f8; border-radius: 10px; padding: .8rem 1rem; margin-bottom: .6rem; }
.result-row { display: flex; justify-content: space-between; align-items: center;
              padding: .2rem 0; border-bottom: 1px solid #dde3e9; font-size: .9rem; }
.result-row:last-child { border-bottom: none; }
.result-row.highlight { font-weight: 700; font-size: 1rem; }
.result-label { color: #555; }
.result-value { font-family: ui-monospace, monospace; }
.verdict { font-size: 1rem; font-weight: 700; min-height: 1.4em; margin-bottom: .3rem; }
.verdict.switch { color: #0a7d33; }
.verdict.keep { color: #c92f3c; }
.verdict.neutral { color: #555; }
.explanation { font-size: .82rem; color: #444; line-height: 1.5; margin-bottom: .6rem; }
button { font: 600 13px system-ui, sans-serif; padding: .4rem .8rem; border: 1px solid #1d3557;
         background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; margin-bottom: .5rem; }
.naive-box { background: #fff3cd; border: 1px solid #ffc107; border-radius: 8px;
             padding: .7rem; font-size: .85rem; line-height: 1.5; }
.naive-box p { margin: .3rem 0 0; }
.naive-warn { color: #c92f3c; font-weight: 600; }
.hidden { display: none; }
// Two Envelopes: compute true expected gain from switching given a prior over the smaller amount
// Prior distributions over the smaller envelope amount m

function priorDensity(type, m) {
  // Return the prior density (or mass) at m
  if (m <= 0) return 0;
  if (type === 'uniform') {
    // Uniform prior: m equally likely in [1, 50]
    return (m >= 1 && m <= 50) ? 1 / 50 : 0;
  }
  if (type === 'geometric') {
    // Geometric prior: m is a power of 2 with geometric probability over exponent
    const p = 0.5;
    const k = Math.round(Math.log2(m));
    if (k < 0) return 0;
    return Math.abs(m - Math.pow(2, k)) < 0.01 ? Math.pow(1 - p, k) * p : 0;
  }
  if (type === 'exponential') {
    // Exponential prior: m ~ Exp(lambda), continuous, decaying density
    const lambda = 0.05;
    return lambda * Math.exp(-lambda * m);
  }
  return 0;
}

function computeGain(type, x) {
  // Posterior probabilities of Case A (your envelope is the smaller) and Case B (it is the larger)
  const px  = priorDensity(type, x);
  const pxh = priorDensity(type, x / 2);
  const total = px + pxh;
  if (total < 1e-15) return { pA: 0.5, pB: 0.5, ev: x, gain: 0, degenerate: true };
  const pA = px  / total;   // posterior prob your envelope is the smaller one
  const pB = pxh / total;   // posterior prob your envelope is the larger one
  const ev = 2 * x * pA + (x / 2) * pB;
  return { pA, pB, ev, gain: ev - x, degenerate: false };
}

const priorSelect = document.getElementById('prior-select');
const xRange      = document.getElementById('x-range');
const xVal        = document.getElementById('x-val');
const valX        = document.getElementById('val-x');
const valPa       = document.getElementById('val-pa');
const valPb       = document.getElementById('val-pb');
const valEv       = document.getElementById('val-ev');
const valGain     = document.getElementById('val-gain');
const verdict     = document.getElementById('verdict');
const explanation = document.getElementById('explanation');
const naiveBox    = document.getElementById('naive-box');
const btnNaive    = document.getElementById('btn-naive');

const EXPLANATIONS = {
  switch_uniform:      'With a uniform prior on [$1,$50], x is within the support so both cases (m=x or m=x/2) are possible. The naive symmetry still holds here — but at x>$50 it breaks completely.',
  keep_uniform:        'With a uniform prior on [$1,$50], x exceeds the maximum smaller amount ($50). Case A (m=x) is impossible — your envelope must be the larger one, so the other holds x/2. Keep it.',
  neutral_uniform:     'At this value of x the prior assigns equal weight to both cases, making switching neither beneficial nor harmful.',
  switch_geometric:    'With a geometric prior (powers of 2), the distribution is scale-free and symmetric — the gain is exactly zero. Switching is pointless. The naive 5x/4 argument is exposed as false.',
  keep_geometric:      'With a geometric prior (powers of 2), the distribution is scale-free and symmetric — the gain is exactly zero.',
  neutral_geometric:   'With a geometric prior (powers of 2), the distribution is symmetric across all scales — expected gain is always zero.',
  switch_exponential:  'With a decaying exponential prior, small amounts are much more probable. Seeing a small x makes the higher value (2x) the likely other envelope.',
  keep_exponential:    'With a decaying exponential prior, large x is very unlikely as the smaller amount. Your envelope is probably the larger one; the other holds x/2.',
  neutral_exponential: 'At this value of x the exponential prior gives roughly equal posterior weight to both cases.'
};

const VERDICTS_SWITCH  = 'Switch — expected gain is positive with this prior.';
const VERDICTS_KEEP    = 'Keep — expected gain is negative; the other envelope is likely smaller.';
const VERDICTS_NEUTRAL = 'Indifferent — no gain expected from switching with this prior.';

function update() {
  const type = priorSelect.value;
  const x    = Number(xRange.value);
  xVal.textContent = x;
  valX.textContent = '

Notice: with a uniform prior on a bounded range, switching is sometimes beneficial and sometimes harmful depending on xx — there is no universal "always switch." With the geometric prior, the expected gain is exactly zero: the two envelopes are symmetric and swapping is irrelevant. The naive argument that gave +25%+25\% was implicitly using an improper flat prior over all positive reals, which does not define a valid probability distribution.

+ x; const { pA, pB, ev, gain, degenerate } = computeGain(type, x); valPa.textContent = (pA * 100).toFixed(1) + '%'; valPb.textContent = (pB * 100).toFixed(1) + '%'; valEv.textContent = '

Notice: with a uniform prior on a bounded range, switching is sometimes beneficial and sometimes harmful depending on xx — there is no universal "always switch." With the geometric prior, the expected gain is exactly zero: the two envelopes are symmetric and swapping is irrelevant. The naive argument that gave +25%+25\% was implicitly using an improper flat prior over all positive reals, which does not define a valid probability distribution.

+ ev.toFixed(2); valGain.textContent = (gain >= 0 ? '+' : '') + '

Notice: with a uniform prior on a bounded range, switching is sometimes beneficial and sometimes harmful depending on xx — there is no universal "always switch." With the geometric prior, the expected gain is exactly zero: the two envelopes are symmetric and swapping is irrelevant. The naive argument that gave +25%+25\% was implicitly using an improper flat prior over all positive reals, which does not define a valid probability distribution.

+ gain.toFixed(2); let state; if (degenerate || Math.abs(gain) < 0.005) { state = 'neutral'; verdict.textContent = VERDICTS_NEUTRAL; verdict.className = 'verdict neutral'; } else if (gain > 0) { state = 'switch'; verdict.textContent = VERDICTS_SWITCH; verdict.className = 'verdict switch'; } else { state = 'keep'; verdict.textContent = VERDICTS_KEEP; verdict.className = 'verdict keep'; } explanation.textContent = EXPLANATIONS[state + '_' + type] || ''; } btnNaive.addEventListener('click', () => { naiveBox.classList.toggle('hidden'); }); priorSelect.addEventListener('change', update); xRange.addEventListener('input', update); update();
Result
Console

Notice: with a uniform prior on a bounded range, switching is sometimes beneficial and sometimes harmful depending on xx — there is no universal "always switch." With the geometric prior, the expected gain is exactly zero: the two envelopes are symmetric and swapping is irrelevant. The naive argument that gave +25%+25\% was implicitly using an improper flat prior over all positive reals, which does not define a valid probability distribution.

The Real Flaw

The naive argument fails because it treats the observed amount as if it gives symmetric information about both possibilities. Here is why that breaks down.

Let the smaller amount be mm (unknown). Your envelope holds either mm or 2m2m, each with probability 12\frac{1}{2}. If you see xx:

  • Case A: your envelope is the smaller — then m=xm = x and the other holds 2x2x.
  • Case B: your envelope is the larger — then m=x/2m = x/2 and the other holds x/2x/2.

The posterior probability of Case A vs. Case B depends entirely on your prior over mm. If your prior gives P(m=x)P(m = x) and P(m=x/2)P(m = x/2), then by Bayes:

P(Case A∣x)=P(x∣A) p(x)P(x∣A) p(x)+P(x∣B) p(x/2)=p(x)p(x)+p(x/2)P(\text{Case A} \mid x) = \frac{P(x \mid \text{A})\, p(x)}{P(x \mid \text{A})\, p(x) + P(x \mid \text{B})\, p(x/2)} = \frac{p(x)}{p(x) + p(x/2)}

The expected value of the other envelope is:

E[other∣x]=2x⋅P(A∣x)+x2⋅P(B∣x)E[\text{other} \mid x] = 2x \cdot P(\text{A} \mid x) + \frac{x}{2} \cdot P(\text{B} \mid x)

This equals xx (no gain from switching) only when p(x)=p(x/2)p(x) = p(x/2) for all xx — which requires a distribution uniform over all powers of 2, which does not exist as a proper probability measure.

The naive argument implicitly uses an improper flat prior p(m)∝1p(m) \propto 1 over (0,∞)(0, \infty), which is not a valid distribution. Every proper prior breaks the symmetry at some scale, and for any bounded or geometric prior the gain from switching can be negative, zero, or positive — depending on xx relative to the prior's support. This connects to deeper issues in Bayesian inference about non-informative priors.

Where It Matters

The two-envelopes trap is not just an abstract puzzle — the same logical flaw appears throughout computer science and decision theory:

  • Optimal stopping (secretary problem): deciding when to accept the "current best" requires a model of the underlying distribution. Without one, no stopping rule is universally optimal — just like no switching rule beats the two-envelope argument.
  • Algorithm analysis: comparing two unknown quantities ("is this solution better than the last?") can lead to infinite regress if the comparison assumes scale-free distributions that don't exist.
  • Game theory and adversarial settings: an opponent who knows you always switch will exploit you. The correct strategy depends on beliefs — priors — about the game state.
  • Bayesian model selection: choosing between two models by comparing their marginal likelihoods can exhibit the same prior-dependence. The "obviously better" model can flip based on the prior you choose.

The lesson is always the same: expected value without a valid probability model is meaningless. See also Nash equilibrium for how rational agents must reason about uncertainty in strategic settings.

Conclusion

The Two Envelopes Paradox is still open in the sense that there is no universally agreed single resolution — philosophers and mathematicians continue to debate its subtleties. But the core lesson is clear: the naive switching argument is invalid because it implicitly assumes an improper prior distribution that cannot exist.

Once you fix a real, bounded prior over possible amounts, the expected gain from switching is well-defined, finite, and no longer universally positive. Sometimes you should switch, sometimes not — it depends entirely on what you observed and what you believed about the amounts beforehand.

Expected value is one of the most powerful tools in probability. But it is only as trustworthy as the distribution it is computed from. Demand a valid prior, and the infinite-swap loop evaporates.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/two-envelopes/Content licensed under CC BY-NC 4.0.