What number would you bet on to maximize your chances of winning?
Solution 1:
As mentioned in my comment, this depends on what you think your friend will bet.
If your friend bets $14$, then you should bet $14$. (Assuming ties count as half a win.)
If your friend bets $n > 14$, then you should bet $n-1$. Similarly, if your friend bets $n<14$, then you should bet $n+1$.
I'll let you verify that this strategy in fact maximises your probability of winning. One way to help you see this is to fix an $n$ (e.g. $n=20$), and then check that betting anything other than the bet prescribed above (e.g. when $n=20$, you should bet $n-1=19$) will have you winning less often.
Solution 2:
The weighted sum that appears in the expected value doesn't really help with "closest to the value" two-person games. For that, you really want the median.
Consider for instance you choose 13 (the expected value) and I know that somehow. I choose 14 (the median). What is the probability you win?
What if i choose 14 first and you know that? What is the best win probability your guess can give you?
In other words, the maximin strategy in such games is to bet the median.
Solution 3:
Considered as a two-person game, this is incompletely specified, both because there is some residual ambiguity in the specification of your own objective (do you consider a tie to be just as bad as a loss, for instance, or not so bad as a loss but not as good as a win), and no specification whatever of your opponent's objective.
Even if you ignore your opponent's objective entirely, the fact remains that your probability of winning still depends partially on his or her choice of number, so nothing you do can maximise your probability of winning tout court, because you have no control over one of the inputs on which that probability depends. There are, however, a couple assumptions you might make to resolve this difficulty:
- Assume your opponent's goal is the same as yours—i.e. to maximise his or her probability of winning. This turns the problem into a two-person game, for which you can try to find a Nash equilibrium. The game is not constant-sum however, because if both you and your opponent choose the same number, the probabilities of each of you winning sum to zero instead of $1$.
- Ignore your opponent's objective completely, and try instead to maximise what your minimum probability would be if your opponent's choice is the worst possible for whatever strategy you adopt. In this case, you must use a mixed strategy if the worst case is to be one where you have a positive probability of winning).
As it happens, the solution in both cases turns out to be the same: choose $13$ with probability $\ \frac{99}{190}\ $ and $\ 14\ $ with probability $\ \frac{91}{190}\ $ (and keep your choice concealed from your opponent until after he or she has irrevocably chosen his or hers—assuming this is possible). This is your unique Nash equilibrium strategy under the first assumption, and it guarantees that you win with probability $\ \frac{9009}{36100}\approx0.25\ $, which is also the maximum winning probability you can be assured of, because if your opponent chooses the same strategy, then your probability of winning is at most $\ \frac{9009}{36100}\ $, no matter what you do.
You could also turn the game into a $2$-person constant sum game by assuming that both you and your opponent consider a tie to be half as valuable as a win, while still regarding a loss as worthless. In that case your optimal strategy is to choose $14$, which guarantees you an outcome at least as good as a tie. If your opponent chooses any other strategy your expected payoff will be greater than $\ \frac{1}{2}\ $—that is,$$\ \frac{1}{2}\text{Prob}(\text{tie})+\text{Prob}(\text{you win})>\frac{1}{2}\ .$$
Solution 4:
If you choose 14, you win over half the time when your opponent chooses any other number.