Maximizing score in number-guessing game.

This is inspired by a puzzle (related to the two-envelopes problem) that I've seen in several places, including unbounded generalizations. The basic premise is that Alice chooses two real numbers from $[0,1]$ uniformly at random, and writes them down on slips of paper. Bob chooses one slip of paper at random, reads the number, and may either keep that slip or switch for the other. Bob's score is the number he ends up with, and our task is to maximize his expected value. The standard solution is for Bob to choose his own real number uniformly at random, and switch if the number he picks is greater than what's on the slip he holds.

However, this is not the only solution. Bob has one piece of data, $x$, and the use of a random number generator. He can keep his initial slip with some probability $f(x)$ and swap with probability $1-f(x)$. Call this function $f(x)$ his strategy; the standard solution corresponds to strategy $f(x)=x$. We calculate his expected winnings as $$E=\iint_{[0,1]\times[0,1]} f(x)x+(1-f(x))y\, dx dy=\int_0^1f(x)(x-0.5)+0.5\,dx$$

Trying $f(x)=x$ gives $E=0.58\overline{3}$, while $f(x)=x^{1.4}$ gives $E\approx 0.585784$.

UPDATE: In the comments Calvin Lin suggests $f(x)=\begin{cases}0&x<0.5\\1&x>0.5\end{cases}$, with $E=0.6125$.

What's the highest $E$ Bob can achieve, and what is the corresponding $f$?

The maximum, if Bob knew what was on the others slip, is $2/3$, so the answer must be less than that.

• Consider the following strategy: If chosen slip is larger than $\frac{1}{2}$, keep it. Else choose second slip. Then, the expected value is $\int_{\frac{1}{2}}^1 x\, dx + (\frac{1}{2}) \frac{1}{2} = 0.625.$ – Calvin Lin Jul 1 '13 at 2:43
• I'd disagree with your term "theoretical maximum", as it requires Bob to know exactly what the values are in order for him to choose correctly each time. Since this is impossible from the rules, the actual maximum is less than 2/3 (and I believe it is 5/8). – Calvin Lin Jul 1 '13 at 2:48

Consider the following strategy: If chosen slip is larger than $\frac{1}{2}$, keep it. Else choose second slip.

Then, the expected value is $\int_{\frac{1}{2}}^1 x\, dx + (\frac{1}{2}) \int_0^1 y \, dy = 0.625.$

Claim: This is the best possible strategy.

Suppose not, then one of the following must happen

1. Bob picks a number that is larger than $\frac{1}{2}$, and decides to pick the second slip.
2. Bob picks a number that is smaller than $\frac{1}{2}$ and decides to stick to it.

In either case, we can see that Bob increases his expected value by following the initial strategy. (In particular, this strategy is unique, up to a set of measure 0).

• This shows the importance of details in a problem like this. The proposed strategy (accept a number with probability that number) is appropriate if you don't know Alice's strategy. If we are given that Alice picks the numbers uniformly we can do better, as here. – Ross Millikan Jul 1 '13 at 2:53
• @RossMillikan Agreed. If Alice even selects the numbers non-independently (sorry for the abuse, but I think it is a better word than dependently in probability contexts), then the above strategy will have to account for that. – Calvin Lin Jul 1 '13 at 2:54
• dont you need a factor of $\frac{1}{2}$ in front of the first integral? – Daniel Montealegre Jul 1 '13 at 2:58
• @DanielMontealegre No. Would you agree that, given that the first slip is $> \frac{1}{2}$, the expected value should be $\frac{\frac{1}{2} + 1 } { 2} = \frac{3}{8}$? If so, the integral gives us$[\frac{x^2}{2}]_{\frac{1}{2} }^1$, which evaluates to $\frac{3}{8}$. Now, think why the factor is not supposed to be there. – Calvin Lin Jul 1 '13 at 3:00
• oops, yeah the first term is $\frac{1}{2}\int_{1/2}^1 x d(2x)$, thats why they cancel. – Daniel Montealegre Jul 1 '13 at 3:07