# A job interview question on flipping a coin [duplicate]

I was asked the following question during a job interview:

A coin is flipped 1000 times and 560 times heads show up. Do you think the coin is biased?

What would be your answer?

(I find the question "Quantifying 'survey bias' in reports" related (but it is not answered).)

• – Haitao Du May 31 '17 at 16:27
• The reference question was poorly posed and referred to 6 tosses with 5 successes. Still it is possible to apply the binomial to determine the probability that the outcome would occur if the coin was fair. – Michael R. Chernick May 31 '17 at 17:08
• @MichaelChernick i was trying to suggest Glan_b's answer in that question. – Haitao Du May 31 '17 at 17:53
• It seemed to be more of a criticism than an answer. The general question must be duplicated in more than one place. – Michael R. Chernick May 31 '17 at 18:05
• @MichaelChernick agreed. Glen_b was not so happy that day... – Haitao Du May 31 '17 at 19:23

## 6 Answers

The interviewer may also have been using this as a way to see how you nuance language around the discussion of statistical results. Other answers have made it clear, this is a low probability event if the coin is fair. For many, that may be enough evidence to claim bias. However, depending on how the interviewer worded the question (and the context leading up to the question) they may be looking for you to make the distinction that while the "best" available evidence points to it being bias, there is of course no way to know this with absolute certainty.

(Although I would be certain enough evidence for me not to let anyone use that coin to decide who gets the dirty job).

With a large number of independent Bernoulli trials, the sample proportion has an approximate normal distribution by the Central Limit Theorem. With $\hat{p}= 0.56$ and $se(\hat{p}) = \sqrt{0.56(1-0.56)/1000} \approx 0.015$. The sample test statistic for the proportion test of the hypothesis of $p=0.5$ corresponding to the fair coin is $Z \approx (0.56-0.50)/0.015 \approx 4$. Using the normal approximation to the sampling distribution of the test statistic under the null hypothesis, the probability of observing 560 or more, or 440 or less heads is very small, less than 0.001 which is very strong evidence of the coin being unfair.

• Wouldn't you use .5 rather than .56 since you are interested in deviations from what is expected from an unbiased coin? – David Lane Jun 1 '17 at 2:31
• This does not change the result much, but shouldn't we compute the variance under the null in order to calculate the p-value, i.e. with p=0.5 and not with 0.56? – amoeba Jun 1 '17 at 7:15
• @DavidLane it turns out they are both accurate. To use the variance estimate under the null is to conduct a score test. The variance under the alternate (or the empirical variance) is the Wald test. I prefer the latter because it has a 1-1 correspondence with the confidence interval. – AdamO Jun 1 '17 at 15:26
• @AdamO Thx for the explanation. – David Lane Jun 1 '17 at 17:31

Call $X$ the number of heads.

Assume it is not biased. It is the sum of 1000 independent Bernoulli variables with mean $0.5$ and variance $0.5\times 0.5=0.25$. It has mean $500$ and variance $250$. The standard deviation is $\sqrt{250}\approx 16$.

Intuitively $X$ should be 500 +/- 16.

$X$ can be approximated by a normal distribution (1000 is large enough). The question is : what is probability for a normally distributed variable to have a distance to the mean at least $60/16=3.8$ times the standard deviation. You can find it in this table : https://en.wikipedia.org/wiki/Standard_normal_table

$p=1-2*0.49993=0.00014$

As a conclusion, if the coin is unbiased, the probability of a number of heads as great as 560 is 0.014%. This is quite small. The coin is biased quite certainly.

Or you can use a $\chi^2$ test https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test that will yield the same conclusion.

I would talk about normal distributions and standard deviations from the mean.

 Draw a nice normal distribution curve on a board.


Then ASK what is the definition of biased; based on the number of standard deviations from the mean.

I like the "easy" and "certified" answer that can come from having some basic resources. Managers aren't going to understand algebra. You get 5 bullet points and can't say any math at all, but defend your assertion. I have been required to do this. If this is your question in a job interview, especially if the person asking the question doesn't have a math degree, then they want to see if you "speak human".

I would go to this site
http://epitools.ausvet.com.au/content.php?page=CIProportion

I would type in the numbers, and select 'all confidence-interval methods', and hit "submit".

There are good guidelines for which method to use, but they all give a consistent number for the lower interval that does not include 50%.

A non-biased coin would include 50% in its confidence interval.

I would say "this is made by world-class PhD's in stats, and is a government facing AI in epidemiology", so without any other reason than this, we might still believe its numbers are good. Also, all the different methods agree.

Comment:
I was asked in my interview "how many marbles do I need to draw from a bowl in order to make a pair, when there are two colors uniformly randomly distributed", and why.

I would say that it would require some simple calculations. Let $X\sim \operatorname{Binomial}(1000, 0.5)$. If the coin is fair it should be quite likely to get 560 heads out of 1000. So we calculate that probability as: $\Pr(X=560)=\binom{1000} {560}0.5^{560}(1-0.5)^{1000-560}\approx0.00002$. Since the probability of getting 560 heads out 1000 flips if the coin is fair is so very small, I find it very likely to be biased.

• Can you calculate the binomial probability that $X = 500$? I bet it's also very small. – AdamO May 31 '17 at 16:33
• Firstly your calculation can be simplified to $\binom{1000}{560} \times (.5)^{1000}$ which is small, but not much smaller than the probability of getting exactly 500 heads. Surely you wouldn't find getting exactly 500 heads evidence that the coin is unfair ? – meh May 31 '17 at 16:35
• I can tell the OP that what the questioner is looking for is 1)to see if you know what the mean and s.d of the binomial distribution is, 2)to see if you can calculate a 'z score' for this and 3)then conclude using hypothesis testing whether this result is fair. I don't feel like doing the calculations, but that is what is called for. My best guess is that googling 'interview question' & "fair coin question" will get you the exact answer. – meh May 31 '17 at 16:39
• So really the question will be what is the probability of getting 500+/- 60 heads in 1000 fair flips. Of course one uses that binomial is approximately normal. – meh May 31 '17 at 16:40
• The probability of getting 500 heads is more than 1000 times bigger. I buy your arguments though, but my point is that if the coin is fair, it still is very unlikely to get 560 heads. A better way is to perform a hypothesis test, where you test $H_0: p=0.5$. Your point estimate would be 560/1000 and you can then use a one sample test for proportions, e.g. $Z=\frac{\hat{p}-p_0} {\sqrt{\hat{p}(1-\hat{p})/n}}$, where $Z$ is approx $N(0, 1)$. – infstat May 31 '17 at 16:44