sergazy.nurbavliyev@gmail.com © 2021

## Is the coin biased?

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


https://stats.stackexchange.com/questions/282786/a-job-interview-question-on-flipping-a-coin

## Answer

It is already answered pretty nice in the stackexchange website where I give the link above. I would definitely try exactly the same way. 

Since the 1000 sample size is large enough, we can apply the Central Limit Theorem. Assume probability of head is $p$ and probability of tails as $q$. Note $p+q=1$. We want to know if $p=1/2$ or not. 

Assuming each trial are independent of each other, if $p=1/2$ then we should have expected to see 500 heads.
and the variance is given by:
\begin{equation}
\sigma^2= np(1-p)=1000\frac{1}{2}\frac{1}{2}=250 
\end{equation}
then the standard deviation would be $\sqrt{250}=15.81$. Remembering the 68-95-99.7 rule for a Normal Distribution
we can calculate the z-score for 560 heads:
\begin{equation}
z = \frac{560-500}{15.81}=3.79
\end{equation}
Remember that 99.7% of the data lies within 3 standard deviation (15.81) of the mean 500. However, we see that here z lies outside of the 99.7%. In other words, if our coin was fair, then probibility of seeing 560 heads is less than 0.03. This means that, most probably our coin is biased coin.


```python
60/250**(1/2)
```




    3.794733192202055




```python
60
```

## Python code for simulation


```python
import random
trial_list= [sum([random.randint(0,1) for i in range(1000)]) for j in range(1000)]
```


```python
from matplotlib import pyplot as plt
plt.plot(trial_list)
plt.axhline(y=560, color='r', linestyle='-')
plt.show()
```


```python

```


```python

```

0eb84fcb48116c6cb0fa8752f7cea2a25901e0aa
ipynb
Jupyter Notebook
Is the coin biased March 10 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-04T06:48:28.000Z
2021-04-19T10:04:24.000Z
Is the coin biased March 10 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-05T22:00:43.000Z
2021-03-05T22:00:43.000Z
Is the coin biased March 10 2021.ipynb
sernur/probability_stats_interveiw_questions
3144dae00fa83c82ff4e1f7668828349270a1937
MIT
2021-03-04T05:02:00.000Z
2021-03-16T01:13:40.000Z
Qwen/Qwen-72B
1. YES
2. YES