Flip a coin until you wish to stop. Your goal is to maximize the ratio number of heads/total number of flips. What is the expected value of this game? Additionally, how would one play this game?
[Math] Maximizing heads/number of flips game
probability
Related Solutions
Let $N$ be the number of flips needed, and let $E(N)$ be the expected number of flips needed. You always need a flip, but with probability $\frac{1}{9}$ you will not make progress and need to "start over" and flip again, with another $E(N)$ expected flips needed to finish. So
$$E(N) = 1 + \frac{1}{9} E(N).$$
Solving for $E(N)$ gives $\color{blue}{E(N) = \displaystyle\frac{9}{8}}$.
Your bullet points amount to saying that you're going to flip the coin until the number of heads exceeds the number of tails. Suppose that this happens on the $n$-th flip; then after $n-1$ flips you must have had equal numbers of heads and tails, so $n=2m+1$ for some $m$, you now have $m+1$ heads, and the ratio of heads to flips is $\frac{m+1}{2m+1}$. If $p_n$ is the probability of stopping after the $(2n+1)$-st flip, the expected ratio of heads to flips is $$\sum_{n\ge 0}\frac{p_n(n+1)}{2n+1}\;.$$ Thus, the first step is to determine the $p_n$.
Clearly $p_0=\frac12$: we stop after $1$ toss if and only if we get a head. If we stop after $2n+1$ tosses, where $n>0$, the last toss must be a head, half of the first $2n$ tosses must be heads, and for $k=1,2,\dots,2n$ the first $k$ tosses must not include more heads than tails. The problem of counting such sequences is well-known: these are Dyck words of length $2n$, and there are $C_n$ of them, where $$C_n=\frac1{n+1}\binom{2n}n$$ is the $n$-th Catalan number. Each of those $C_n$ sequences occurs with probability $\left(\frac12\right)^{2n}$, and each is followed by a head with probability $\frac12$, so $$p_n=C_n\left(\frac12\right)^{2n}\cdot\frac12\;,$$ and the expected ratio is $$\frac12\sum_{n\ge 0}C_n\left(\frac12\right)^{2n}\frac{n+1}{2n+1}=\frac12\sum_{n\ge 0}\frac1{4^n(2n+1)}\binom{2n}n\;.$$
Very conveniently, the Taylor series for $\arcsin x$ is $$\arcsin x=\sum_{n\ge 0}\frac1{4^n(2n+1)}\binom{2n}nx^{n+1}\;,$$ valid for $|x|\le 1$, so the expected ratio is $$\frac12\sum_{n\ge 0}\frac1{4^n(2n+1)}\binom{2n}n=\frac12\arcsin 1\approx 0.7854\;.$$
Added: I should emphasize that this calculation applies only to the stated strategy. As others have noted, that strategy is known not to be optimal, though it's quite a good one, especially for being so simple.
Best Answer
This seems like a tricky problem. If you are ever below $1/2$, you should keep flipping because the fraction of heads will converge to $1/2$ with probability $1$ if you keep flipping. Also since the number of heads is a random walk, the fraction of heads will go above $1/2$ infinitely often with probability $1$ if you keep flipping, so even if you are at exactly $1/2$ you should keep flipping. If the first flip is heads you should obviously stop. If the first flip is tails and the second two flips are heads you should probably also stop. But as the number of flips increases, things get a bit tricky. The standard deviation of the ratio is proportional to $1/\sqrt{N}$ for $N$ flips, so if the number of flips is large and you keep flipping it seems like your ratio will stay close to $1/2$ with high probability, although occasionally you may get a ratio equal to or above $1/2 + k/\sqrt{N}$ for some small $k$ on the order of $1$ or $10$ or so. The question is what $k$ to stop at as a function of $N$. If you choose $k$ too large, then on average you'll have to wait for a larger $N$ until you hit the ratio, so the expected value of $k/\sqrt{N}$ maybe smaller than if you had chosen a smaller $k$ to wait for.