How many trials of flipping a coin are needed to be confident in getting very close to the same number of H/T? How many times one would need to flip a coin in order to be very confident of getting close to a $1:1$ ratio of Heads/Tails? By "very confident" I mean above $95$% sure, and by "close to a $1:1$ ratio" I'm thinking $55$%-$45$% H/T or T/H.
I'm running of a simulation where two engines are playing a game against each other, and I'm wondering after how many games I should stop the simulation and check their match score (if the score is close to equal after X number of games, I would infer the engines are most likely equal in strength).
I know this is a basic probability/statistics question, but I couldn't find a question addressing this anywhere else.
 A: If you flip $n$ coins, the number of Tails follows a binomial distribution that you can approach with a normal distribution of parameters $\mu=\frac n2$ and $\sigma=\frac{\sqrt{n}}{2}$.
With this approximation, $95\%$ of the time the amount of Tails will fall within $1.96\sigma$ of $\mu$, so in the interval $[\frac {n-1.96\sqrt n}{2},\frac {n+1.96\sqrt n}{2}]$ and in these cases the ratio T/H will be between $\frac {n-1.96\sqrt n}{n+1.96\sqrt n}$ and $\frac {n+1.96\sqrt n}{n-1.96\sqrt n}$.
You want therefore to solve $$\frac {n-1.96\sqrt n}{n+1.96\sqrt n}\geq\frac{45}{55}$$ which is equivalent to $$10n\geq 196\sqrt n$$
and $$\sqrt n \geq 19.6$$ or finally $$n\geq 385$$
If you flip a fair coin at least $385$ times, you are $95\%$ certain to end up with a ratio $T/H$ between $\frac{45}{55}$ and $\frac{55}{45}$.
A: You are asking for the smallest integer $n$ that satisfies:$$P\left(\frac9{20}n\leq X\leq\frac{11}{20}n\right)\geq0.95\tag1$$where $X$ has binomial distribution with parameters $n$ and $p=0.5$.
$X$ has mean $\frac12n$ and variance $\frac14n$ and stating: $$U:=\frac{X-\mu}{\sigma}=\frac{X-\frac12n}{\frac12\sqrt{n}}$$we can rewrite $(1)$ as:$$P\left(-\frac1{10}\sqrt{n}\leq U\leq -\frac1{10}\sqrt{n}\right)\geq 0.95$$
where $U$ has mean $0$, has variance $1$ and has a distribution that can be approximated by standard normal.
