Let's follow the argument carefully, substituting real numbers for variables, to see where we went wrong. In the following, we will assume the envelopes contain $100 and $200. We will consider the two equally likely cases separately, then average the results.

First, take the case that X=$100.

"I have $100 in my hand. If I exchange I get $200. The value of the exchange is $200. The value from not exchanging is $100. Therefore, I gain $100 by exchanging."

Second, take the case that X=$200.

"I have $200 in my hand. If I exchange I get $100. The value of the exchange is $100. The value from not exchanging is $200. Therefore, I lose $100 by exchanging."

Now, averaging the two cases, I see that the expected gain is zero.

So where is the slip up? In one case, switching gets X/2 ($100), in the other case, switching gets 2X ($200), but X is different in the two cases, and I can't simply average the two different X's to get 1.25X. I can average the two numbers ($100 and $200) to get $150, the expected value of switching, which is also the expected value of not switching, but I cannot under any circumstances average X/2 and 2X.

This is a classic case of confusing variables with constants.

OK, so let's consider the case in which I looked into the envelope and found that it contained $100. This pins down what X is: a constant.

Now the argument is that the odds of $50 is .5 and the odds of $200 is .5, so the expected value of switching is $125, so we should switch. However, the only way the odds of $50 could be .5 and the odds of $200 could be .5 is if all integer values are equally likely. But any probability distribution that is finite and equal for all integers would sum to infinity, not one as it must to be a probability distribution. Thus, the assumption of equal likelihood for all integer values is self-contradictory, and leads to the invalid proof that you should always switch. This is reminiscent of the plethora of proofs that 0=1; they always involve some illegitimate assumption, such as the validity of division by zero.

Limiting the maximum value in the envelopes removes the self-contradiction and the argument for switching. Let's see how this works.

Suppose all amounts up to $1 trillion were equally likely to be found in the first envelope, and all amounts beyond that would never appear. Then for small amounts one should indeed switch, but not for amounts above $500 billion. The strategy of always switching would pay off for most reasonable amounts but would lead to disastrous losses for large amounts, and the two would balance each other out.

For those who would prefer to see this worked out in detail:
Assume the smaller envelope is uniform on __$0,$M__?, for some value
of $M. What is the expectation value of always switching? A quarter of
the time $100 >= $M (i.e. 50% chance $X is in $M__/2,$M__? and 50% chance
the larger envelope is chosen). In this case the expected switching
gain is -$50 (a loss). Thus overall the always switch policy has an
expected (relative to $100) gain of (3/4)*$50 + (1/4)*(-$50) = $25.

- However the expected absolute gain (in terms of M) is
/ M | g f(g) dg,

Fatal Error:lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual

lib/DbaDatabase.php:154: Warning: dba_optimize() [<a href='function.dba-optimize'>function.dba-optimize</a>]: You cannot perform a modification to a database without proper access

lib/DbaDatabase.php:160: Warning: DbaDatabase: optimize()

## Fatal PhpWiki Error

lib/CachedMarkup.php (In template 'browse' < 'body' < 'html'):257: Error: Pure virtual