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?


  • $\begingroup$ What is a 1000 coin-flip over 5000 times? In what way is this different from "the whole observe number of heads". Are you saying you have recorded 5 million individual flips ... or the result of 5000 summaries of 1000 flips. How many points in the dataset? And what is the distribution of results? $\endgroup$
    – wolfies
    Commented Dec 23, 2019 at 20:54
  • $\begingroup$ @wolfies Thank you for your comment. It is now edited. $\endgroup$
    – Coder
    Commented Dec 23, 2019 at 22:44
  • $\begingroup$ Can you please provide the code you use? Do you use a distinct seed for each of $5000$ sequences of $1000$ coin flips? $\endgroup$ Commented Dec 24, 2019 at 12:14

1 Answer 1


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.

  • $\begingroup$ That might be one way to look at the problem. But another way might be to ask what is the a priori distribution of biased coins compared to unbiased ones. Do the coins come straight out the mint? Have you come across other biased coins? Or is this an unbiased coin with a sampling distribution just like any random variable? Unless the data suggested clearly otherwise, my natural predilection would be to assume the coin is in fact unbiased, or to weight the calculation by the distribution of biased/unbiased coins. $\endgroup$
    – wolfies
    Commented Dec 23, 2019 at 17:04
  • $\begingroup$ Out of habit, I do not take a Bayesian approach unless one has explicit prior knowledge and a relatively small sample size. $\endgroup$ Commented Dec 23, 2019 at 17:18
  • $\begingroup$ You may also wish to check how the coins were flipped, and whether the sampler is inducing bias in his/her flipping. Never trust a flipper. $\endgroup$
    – wolfies
    Commented Dec 23, 2019 at 17:21
  • $\begingroup$ Within the context of this website, I think it is reasonable to assume proper experimental procedure for such a problem. $\endgroup$ Commented Dec 23, 2019 at 17:55
  • $\begingroup$ The OP says they have "replicated a 1000 coin-flip over 5000 times". How does that match the model you have suggested above? $\endgroup$
    – wolfies
    Commented Dec 23, 2019 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.