There is a game where you get to pick a number between 1 and 1000 and then the system will tell if you guessed to high or too low. Using a binary search you can find the answer in a maximum of ten guesses (2^10 = 1024) , but how would I go about calculating the average number of guesses required to guess the given method, assuming the user uses this binary chop method?
Probability – Average Number of Guesses to Guess Number Between 1 and 1000?
probabilitystatistics
Related Solutions
A definite answer is very hard to give because there is a lot of convoluted strategy involved. A rough information theoretical approximation is as follows. We have to guess 30 bits of information and the first round gives us about $1.94$ bits, so we might know all after about 16 rounds. However, on the one hand we can increase the expected information gain (though hardly ever to the maximum of $2.58$ bits), on the other hand the information to be gained about five selected people may be less due to knowledge gained in previous rounds.
You can work with a lower bound by assuming the trivial strategy that makes random guesses in each round and only making use of rounds where you guess all correct. As a slight improvement, you may choose to always repeat the known correct giuess for people already solved. However we ignore the fact that all-wrong-guesses can be used to strike away one bad for each of the five people and other advantages. Under this strategy, let $X_n$ be the number of solved people after $b$ rounds. So $X_0=0$ and otherwise $$\begin{align}P(X_{n+1}=k)=&\frac1{1024}\cdot \frac{20-k\choose 5}{15\choose 5}P(X_n=k-5) \\&+ \frac1{256}\cdot \frac{{19-k\choose 4}{k-4\choose 1}}{15\choose 5}P(X_n=k-4)\\&+ \frac1{64}\cdot \frac{{18-k\choose 3}{k-3\choose 2}}{15\choose 5}P(X_n=k-3)\\ &+\frac1{16}\cdot \frac{{17-k\choose 2}{k-2\choose 3}}{15\choose 5}P(X_n=k-2)\\ &+\frac1{4}\cdot \frac{{16-k\choose 1}{k-1\choose 4}}{15\choose 5}P(X_n=k-1)\\ &+\frac{{k\choose 5}}{15\choose 5}P(X_n=k)\\\end{align}$$ (especially, $P(X_n=1)=\ldots=P(X_n=4)=0$) You can use this recursion to estmiate the expected number of rounds until you know all birthdays: $$E(all)=\sum_{n=0}^\infty P(X_n<15) $$
The answer is that $2^7=128>100$.
To be more precise:
Say that you start by guessing $50$. Either you're right, in which case you're done, or you're wrong; if you're wrong, then you know that the number is either in $[1,49]$ or $[51,100]$, so that there are only $49$ or $50$ possibilities left.
Now, assuming that you aren't already done, you have a collection of $49$ or $50$ possibilities left; guess the middle one. That is, if you are on $[1,49]$, guess (say) $25$; if you're on $[51,100]$, then guess (say) $75$. If you got it right: great. If not, then you find out whether it should be higher or lower; in particular, if you previously knew it was in $[1,49]$, then you either now know it is in $[1,24]$ or you now know it is in $[26, 49]$. If you previously knew it was in $[51,100]$, then either you know that it is in $[51,74]$ or that it is in $[76,100]$.
In any case, you have either already guess right, or you have narrowed down the possibilities to one of $[1,24]$, $[26,49]$, $[51,74]$, or $[76,100]$. In any one of these cases, there are at most $25$ possibilities left, and it must be one of them.
Continue in this way: cut your current interval of possibilities in half by a guess, so that you are either right or you can discard roughly half of the possibilities based on the announcement of "higher" or "lower".
By continuing this process, in the third step you narrow it down to at most $12$ possibilities; in the fourth, to at most $6$; in the fifth, to at most $3$; in the sixth, to at most $1$; and voila! In your seventh guess, assuming that you're unlucky enough to have not guessed it yet, there's only one number that could possibly be it.
Best Answer
Let us take the more ideal case of guessing integers between $1$ and $2^{10}-1=1111111111_2$ writing in base $2$ from now on without explicitly writing subscript $2$ each time. Then the algorithm for the guesses will be like this:
So we see that the game terminates whenever there are only zeros remaining right of $x_n1$. Then note that there are $2^{n-1}$ binary strings $x_n$ of length $(n-1)$. So $2^{n-1}$ numbers are guessed after exactly $n$ guesses. So for this setup the expected number of guesses will be, returning to writing in base $10$: $$ \frac{1}{2^{10}-1}\sum_{n=1}^{10}n\cdot 2^{n-1}=\frac{9217}{1023}\approx9.00978 $$ So the average case here is very close to the worst case of $10$ guesses. This could seem odd at first, but odd is also the clue here ... Half of the time it takes $10$ guesses to reveal that the randomly picked number $x$ is in fact odd. The first $9$ guesses fills up with zeros which in base $2$ means "divisible by $2$". One quarter of the time $x$ is divisible by $2^2=4$ forcing the algorithm to make $9$ guesses before succes. And so on.
I wrote the following code in Python:
which responded with $8987$, so the average for the $1$ to $1000$ case, assuming that we always make the guess of the rounded average of the limits of the interval we know that $x$ belongs to, must be $8.987$ guesses.