Optimizing total winnings in a probabilistic game played repeatedly, where you may retry with a partial refund if not satisfied In a game that cost $1$ "dollar" to play, you can get "points" equal to a continuous random variable $A$ (with some probability density function).
After seeing the result, you can either:

*

*Keep the points (so you use $1$ dollar to get $A$ points)

*Retry, and get refund of $(1-r)$ dollars, and give up the points  (so you use $r$ dollars to get $0$ points)

The game is played repeatedly for sufficiently many times.
You decided that you would retry if $A < A_0$, where $A_0$ is a constant. How to find $A_0$, so that expected value of points per dollars spent is maximized?

I think the answer may be the same if the game is to end once the points are kept. Playing the game many times would be doing that repeatedly. Also the distribution below $A_0$ shouldn't matter, as they are all discarded because of retries.
The question is inspired by a mobile game I am playing, where teams use up limited "stamina" to attack the boss ~20 times (I guess it is close enough) , and the goal is to maximize "damage". 11/12 of stamina is refunded if retrying (i.e. r = 1/12). In one example, roughly A ~ N(2.5e9, 1e9), but I am also interested in how to find the answer for arbitrary p.d.f.
 A: For a large number of plays there will be a linear relationship between the number of dollars we have and the number of points we expect to get. So let $q$ be the value of a point in dollars (depending on $a_0$, which I’ll write in lowercase in accordance with convention).
The value of a single game is one dollar, so
$$
1 = (1-r)\int_0^{a_0}p_A(a)\mathrm da+q\int_{a_0}^\infty ap_A(a)\mathrm da\;.
$$
Thus we want to minimize
$$
q=\frac{1-(1-r)\int_0^{a_0}p_A(a)\mathrm da}{\int_{a_0}^\infty ap_A(a)\mathrm da}\;.
$$
Setting (the numerator of) the derivative with respect to $a_0$ to zero yields
$$
-(1-r)p_A(a_0)\int_{a_0}^\infty ap_A(a)\mathrm da+a_0p_A(a_0)\left(1-(1-r)\int_0^{a_0}p_A(a)\mathrm da\right)=0\;.
$$
Divide by $-(1-r)p_A(a_0)$:
$$
\int_{a_0}^\infty ap_A(a)\mathrm da+a_0\left(\int_0^{a_0}p_A(a)\mathrm da-\frac1{1-r}\right)=0\;.
$$
This looks a bit ugly for a normal distribution, but let’s work it out for a uniform distribution on $[0,L]$:
$$
\frac1L\int_{a_0}^La\mathrm da+a_0\left(\frac1L\int_0^{a_0}\mathrm da-\frac1{1-r}\right)=0
$$
and thus
$$
\frac{L^2-a_0^2}{2L}+a_0\left(\frac{a_0}L-\frac1{1-r}\right)=0\;.
$$
Multiply by $2L$ and simplify:
$$
a_0^2-\frac{2a_0L}{1-r}+L^2=0\;.
$$
The solution of this quadratic equation in $a_0$ in the feasible interval $[0,L]$ is
$$
a_0=\frac L{1-r}\left(1-\sqrt{2r-r^2}\right)\;,
$$
which, as expected, is $L$ for $r=0$ (if you get a complete refund, you’ll reroll until you get $L$) and $0$ for $r=1$ (if you don’t get any refund, you’ll never reroll). The corresponding price $q$ for a point is
\begin{eqnarray}
q
&=&
\frac{1-\frac{(1-r)a_0}L}{\frac1{2L}\left(L^2-a_0^2\right)}
\\[5pt]
&=&2\cdot\frac{L-(1-r)a_0}{L^2-a_0^2}
\\[5pt]
&=&
\frac2L\cdot\frac{\sqrt{2r-r^2}}{1-\left(\frac1{1-r}\right)^2\left(1-\sqrt{2r-r^2}\right)^2}
\\[5pt]
&=&
\frac{\sqrt{2r-r^2}+1}L\;.
\end{eqnarray}
As expected, this is $\frac1L$ for $r=0$ (if you get a complete refund and keep rerolling until you get $L$, a dollar buys $L$ points) and $\frac2L$ for $r=1$ (if you don’t get any refund, a dollar just buys the mean $\frac L2$ of the uniform distribution of points).
