Take any probability distribution defined on the set of all values (x,y) where x and y are non-negative reals and y=2x. It can be discrete, continuous, or a mixture.
Let p(x) be the marginal distribution over x. This method of defining p avoids the distinction between choosing x and then doubling it, or choosing y and then halving it, or any other method of choosing (x,y) such that y=2x.
Assume that p has an expected value, denoted by E(p).
The expected value of switching when the amount in the first envelope is in the range [x−dx/2,x+dx/2] consists of two parts:
(i) The first envelope contains the smaller amount. This has probability p(x)dx/2+O(dx2). The division by 2 comes from the 50% chance of choosing the envelope with the smaller amount.
(ii) The first envelope contains the larger amount. This has probability p(x/2)dx/4+O(dx2). The extra factor of 2 comes from the fact that when the contents are in an interval of length dx, half of that (the amount chosen by the envelope-filler) is in an interval of length dx/2.
In the two cases the gain from switching is respectively x+O(dx) or −x/2+O(dx).
The expected gain given the contents is therefore xp(x)/2−(x/2)p(x/2)/4+O(dx).
Multiply this by dx, let dx tend to 0 (eliminating the term in O(dx2)) and integrate over the real line:
∫∞0(xp(x)/2−(x/2)p(x/2)/4)dx
=∫∞0xp(x)/2dx−∫∞0(x/2)p(x/2)/4dx
The first integral is E(p)/2. In the second, substitute y=x/2 (therefore dx=2dy), giving ∫∞0yp(y)/2dy=E(p)/2. The two integrals cancel.
Here’s the general calculation.
Take any probability distribution defined on the set of all values (x,y) where x and y are non-negative reals and y=2x. It can be discrete, continuous, or a mixture.
Let p(x) be the marginal distribution over x. This method of defining p avoids the distinction between choosing x and then doubling it, or choosing y and then halving it, or any other method of choosing (x,y) such that y=2x.
Assume that p has an expected value, denoted by E(p).
The expected value of switching when the amount in the first envelope is in the range [x−dx/2,x+dx/2] consists of two parts:
(i) The first envelope contains the smaller amount. This has probability p(x)dx/2+O(dx2). The division by 2 comes from the 50% chance of choosing the envelope with the smaller amount.
(ii) The first envelope contains the larger amount. This has probability p(x/2)dx/4+O(dx2). The extra factor of 2 comes from the fact that when the contents are in an interval of length dx, half of that (the amount chosen by the envelope-filler) is in an interval of length dx/2.
In the two cases the gain from switching is respectively x+O(dx) or −x/2+O(dx).
The expected gain given the contents is therefore xp(x)/2−(x/2)p(x/2)/4+O(dx).
Multiply this by dx, let dx tend to 0 (eliminating the term in O(dx2)) and integrate over the real line:
∫∞0(xp(x)/2−(x/2)p(x/2)/4)dx
=∫∞0xp(x)/2dx−∫∞0(x/2)p(x/2)/4dx
The first integral is E(p)/2. In the second, substitute y=x/2 (therefore dx=2dy), giving ∫∞0yp(y)/2dy=E(p)/2. The two integrals cancel.