How to find the probability of getting heads of an unknown coin when having the number of heads and trials? As a new learner of the statistics I have a basic question. Suppose we have a coin without knowing whether it is biased or not and accordingly we don't know the probability of getting a head in a single flip. We have replicated a 1000 coin-flip over 5000 times. The mean observed number of heads is calculated as follows
$\frac{1}{5000} \sum_{i=1}^{5000} a_i$
where each $a_i$ is the number of heads observed in each 1000 flips.
What is a robust way of calculating the accurate probability of getting a head in a single coin flip?
Thanks.
 A: Let's call a binary experiment one with only two possible outcomes: success and failure.
The binomial distribution $Bin(n,p)$ with parameters $n \in \mathbb{N}_0$ and $p \in (0,1)$ is the probability distribution of the number of successes in a sequence of $n$ independent binary experiments, where the probability of success for each individual experiment equals $p$. Coin flips are your experiments and heads are your successes.
If $X \sim Bin(n,p)$, then $P(X=k)= {n\choose k}p^k(1-p)^{n-k}$ for $k \in \{0,...,n\}$.
The likelihood function of the binomial model is just the probability function viewed as a function of the parameters of the model given the data, i.e. the result of the experiments, $$ \mathcal{L}(p|n,x) = {n\choose x}p^x(1-p)^{n-x},$$ 
where $x$ is the number of successes and $n$ the number of experiments.
Its natural logarithm is given by $$ \log{n\choose x} + x \log{p} + (n-x) \log(1-p).$$ 
To maximise $\log{\mathcal{L}(p|n,x)}$ as a function of $p$ is to maximise $$x \log{p} + (n-x) \log(1-p). $$
By differentiation, one finds that the maximum (log-)likelihood is achieved by $\hat{p}=\frac{x}{n}$.
So, the maximum likelihood estimator of the probability of a success in a single experiment is the proportion of successes over all independent experiments. This estimator is known to be unbiased. See https://en.wikipedia.org/wiki/Binomial_distribution for helpful documentation.
