I found a fun problem on reddit some time ago:

A number is randomly selected between two bounds. Each player can make one guess, the closest to the selected number wins.

The author of this comment notes that they "always use a random number generator for [their] pick rather than guessing to avoid accidentally clustering with others". This relies on the idea illustrated by this reddit thread, that people tend to favour the same numbers when asked to make a random choice, thus generating non-uniform distributions that can create lumps. Picking a number from a uniform distribution might then increase the chances to pick it in a less preferred region, and thus, the chances to be the closest from the target.

But could we do better than that? What is the optimal strategy?

# Against unbiased opponents

We could start assuming that the opponents are unbiased and all pick numbers from the uniform distribution on the allowed range. Knowing that, where should we play?

First of all, we should decide on a couple of details on the lottery that we will be modelling: discrete (we can pick any integer from to included), or continuous (we can pick any real number between and ), and what should we do in case of tie. These rules lead to slightly different behaviours, but I suggest we study both the discrete and continuous cases. Ties will not happen in the continuous case, but in the discrete case, we could either

- give a whole prize to everyone tied first;
- make another lottery among only the people tied first, and repeatedly until only one person remains;
- split the prize equally between the people tied first;
- decide that everyone lost.

The second case is a bit more delicate to study because it would be reasonable to allow a change of strategy between the rounds, depending on the number of opponents, so I propose that we restrain ourselves to the simple cases where ties cause the prize to be either multiplied, split, or destroyed.

## Discrete case

We are searching for the winning expectancy against opponents, if we play at (between and ).

Assume the selected number is . Then we can count the number of numbers at the same distance from the target as we are: such that . This will be or . We can also count the number of numbers farther from the target than we are: such that . If of our opponents are at the same distance from the target as we are, and all the others are farther, then in case we split the prize, we win of the prize. This happens with probability for given and . The total winning expectancy is then

From this graph, we indeed win every time when we have no opponent, we win less often as the number of opponents increases, and picking the middle region seems in general to be a good choice.

But as the number of opponents goes up, the winning expectancy goes down and it becomes more difficult to distinguish the strategy. To make it appear more clearly, I will normalize each curve such that their integrals are equal (more precisely I divide them by the total winning expectancy for this number of opponents).

What jumps to the eye is that for enough opponents, the best strategy is not to play in the middle any more. We can also note that the strategies against 1 or 2 opponents are identical. Finally, when the number of opponents becomes very large, the best strategy becomes to chose uniformly: indeed in this case all the numbers will probably have been chosen by several people, so that we only win if we pick exactly the selected number.

Similar reasoning allows to obtain formulas for the other rules:

## Continuous case

A closed-form formula is easier to find for the continuous case: following a similar reasoning, the winning expectancy if we play at against opponents is

A small advantage seems to subsist in the continuous case, since we can make a guess as close to the border as we want. The positions of the two peaks of the strategy and are such that when tends to infinity, and , the demonstration of these properties is left as an exercise to the reader.

# Back to the real world

Ok but the point of the reddit post was that humans don't pick numbers uniformly. What does everything become if the selected number is still uniformly random, but the opponents pick at random according to the distribution given in the post (favouring 7 and choosing infrequently 10 or 1)?

Depending on the rules of the lottery, it is either beneficial to pick the 7, or to avoid the 7. Until at some point, the less preferred numbers 10 and 1 become the best options, at least in the versions that encourage winning alone (all ties lose, and to a lesser extent all ties split).

But as nice as all this seems, I wouldn't encourage betting your house with this strategy. Indeed, it assumes random opponents and is not protected against smart opponents which might observe you play a couple of times and adapt their strategy accordingly. To handle this kind of adversaries, we can't play the same number every time: a constant strategy would be too easy to exploit. We then need a mixed strategy, which is a probability distribution over our possible actions. This will be for another post.