3

The 100 sided die problem has been asked before:

100-sided die probability.

You are given a 100-sided die. After you roll once, you can choose to either get paid the dollar amount of that roll OR pay one dollar for one more roll. What is the expected value of the game? There is no limit on number of rolls.

The solution amounts to solving the equation, where the floor function is necessary because of the discrete die:

(1)$E=\dfrac {\lfloor E-1\rfloor }{100}\cdot \left( E-1\right) + \left( 1-\dfrac {\lfloor E-1\rfloor }{100}\right)\cdot\dfrac {\lfloor E\rfloor +100}{2} $

eg. Say the expected value is 87.5, you would roll again if you got x≤86 as your expected value is 86.5 after one roll (E-1), so with probability 86/100 your expected value would be E-1, if you got 87 or above, then obviously your expected value is $\dfrac {(100+87)}{2}$

The solution is $\dfrac {1223}{14}$

Now how do you solve that equation, without a numerical approach ?

I know that setting $\lfloor E\rfloor $= B and then writing the equation in terms of E, finding the roots ie when E is maximised, somehow works.

ie. $E = \dfrac {(B^2 + B - 10102)}{(2 (B - 101)} $

Then find the B that maximises this equation, which is $B = 101 - 10\sqrt {2}$, then try the nearest integer values, $\lceil B\rceil $, $\lfloor B\rfloor $ and see which one maximises the equation.

Does anybody know why that works and is that the best way to solve the equation, as this is an interview question after all?

JimSi
  • 531

2 Answers2

0

The reason your substitution works is that the equation is a nice smooth quadratic. If the maximum is between two integer inputs, the highest value with an integer input will be on one side of the maximum or the other. If the degree is higher it usually still works, though you can find cases where it doesn't.

This is a fine approach for solving it.

Ross Millikan
  • 383,099
  • Ok, I guess yes, for a quadratic, the maximum integer has to be one side of the maximum, and then the equation still holds, because B is the maximum integer value. So what other approaches are there to solving it non-numerically?, I would be very interested. – JimSi May 31 '18 at 15:51
  • I usually do what you did. Ignore the floor functions and find the maximum taking the independent variable to be real, then look at the integers on each side. – Ross Millikan May 31 '18 at 15:55
  • ok I apologise as I have managed to confuse myself again. Say the equation was

    $E=-\lfloor E\rfloor ^{2}+L\left[ E\right] +196.5$, then , setting $\lfloor E\rfloor$ = B , and finding the maximum, does not work? while using inequalities as dan_fulea does in his answer finds the correct answer, of E = 14.5

    – JimSi Jun 02 '18 at 08:31
0

Let $E$ be the solution of the above equation $(1)$.

Let $B=\lfloor E\rfloor$, so $B\le E<B+1$, then we use $\lfloor E-1\rfloor=B-1$ to rewrite $(1)$ as $$ (2)\qquad E \underbrace{\left(1-\frac{B-1}{100}\right)}_{>0} = -\frac {B-1}{100} + \left( 1-\frac {B-1}{100}\right) \cdot \frac {B +100}{2} \ . $$ (The positive term is so, since we cannot win more than $100$ in the game.)

This implies the double inequality restricting $B$, $$ (3)\qquad B\cdot \frac{101-B}{100} \ \overset{(L)}\le\ -\frac {B-1}{100} + \frac {101-B}{100} \cdot \frac {B +100}{2} \ \overset{(R)}<\ (B+1)\cdot \frac{101-B}{100}\ . $$ To find a "good" $B$, we consider the corresponding functions of second degree, then their roots.

  • For the left inequality (L), we have equality for the values $$ B^L_{1,2}=\frac 12(203\pm 2\sqrt{89}) \ ,\qquad B_1^L<B_2^L\ , $$ and the inequality prescribes $B\not\in[B_1^L,B_2^L]$, and this excluded interval is numerically $[\ \color{red}{87.34}90283019150, \ 115.650971698085\ ]$,

  • for the right inequality (R), we have equality for the values $$ B^R_{1,2}=\frac 12(201\pm 2\sqrt{89}) \ ,\qquad B_1^L<B_2^L\ , $$ and the inequality prescribes $B\in[B_1^R,B_2^R]$, and this interval is numerically $[\ \color{red}{86.34}90283019152, \ 114.650971698085\ ]$.

The only matching $B\in\Bbb N$ is $$ B= 87\ .$$ (So it "must be" the value, the backwards implication.)

Using (1), or (2), or $E=g(B)=(B^2+B-10102)/(2(B-1))$, we get the promised value for $E$, $E=g(87)=1223/14$.

Comment: The above is a low level way to proceed. The posted maximality for the function relating $E$ and $B$, $E=g(B)$, is not involved. But there may be a speculative connection, as seen above in $(L)$, we take $B$ to be the maximal solution of (L), equivalently written $B=g(B)$. (Since this maximal solution is the only one that respects also (R). This explains why we take the integer $B$ making $g$ maximal.)

dan_fulea
  • 37,952