# Understanding solution of tossing a coin 400 times..

Why in this If, tossing a coin 400 times, we count the heads, what is the probability that the number of heads is [160,190]? question heropup's asnwer is like that?

I don't understand the blue text, I think it should be 190 instead of $\color{blue}{200}.$

And why to do this step $\color{blue}{\Pr[159.5 \le X \le 200.5] }?$ when you can pass directly to standarization.

With $n = 400$ trials, the exact probability distribution for the number of heads $X$ observed is given by $X \sim {\rm Binomial}(n = 400, p = 1/2)$, assuming the coin is fair. Since calculating $\Pr[160 \le X \le \color{blue}{200}]$ requires a computer, and $n$ is large, we can approximate the distribution of $X$ as ${\rm Normal}(\mu = np = 200, \sigma^2 = np(1-p) = 100)$. Thus \begin{align*} \Pr[160 \le X \le 200] &\approx \color{blue}{\Pr[159.5 \le X \le 200.5] }\\ &= \Pr\left[\frac{159.5 - 200}{\sqrt{100}} \le \frac{X - \mu}{\sigma} \le \frac{200.5 - 200}{\sqrt{100}} \right] \\ &= \Pr[-4.05 \le Z \le 0.05] \\ &= \Phi(0.05) - \Phi(-4.05) \\ &\approx 0.519913. \end{align*} Note that we employed continuity correction for this calculation. The exact probability is $0.5199104479\ldots$.

A similar calculation applies for $\Pr[160 \le X \le 190]$. Using the normal approximation to the binomial, you would get an approximate value of $0.171031$. Using the exact distribution, the probability is $0.17103699497659\ldots$.

• Looks like that was a typo. Read the last paragraph of his answer. – saulspatz Apr 27 '18 at 4:53
• ah I see :) so first question is solved, what about second answer? – user441848 Apr 27 '18 at 5:10
• Just imitate the calculations, using $190.5$ instead of $200.5$. – saulspatz Apr 27 '18 at 5:13

As mentioned in the linked post, if $X \sim \mathsf{Binom}(400, .5),$ then $$P(160 \le X \le 200) = P(159 < X < 201) = P(159.5 < X < 200.5) = 0.5199$$ to four places. [The computation is from R statistical software, in which pbinom is a binomial CDF.]

pbinom(200, 400, .5) - pbinom(159, 400, .5)
[1] 0.5199104


Computing with the normal approximation, it is best to use the form $P(159.5 < X < 201.5)$ because that gives the best fit for using the continuous normal distribution to get probabilities for the discrete binomial distribution. The approximating normal distribution is $\mathsf{Norm}(\mu=200,\, \sigma = 10).$

Using endpoints 160 and 200 gives the normal approximation 0.49997, which is a little too small.

diff(pnorm(c(160,200), 200, 10))
[1] 0.4999683


Using the endpoints 159 and 201, we get 0.53980 (a little too large).

diff(pnorm(c(159,201), 200, 10))
[1] 0.5398072


With the endpoints 159.5 and 200.5, we get 0.5199, which is very nearly the correct answer. [All three normal approximations are done using software, which gives slightly more accurate values than are often possible from printed normal tables of the standard normal distribution.]

diff(pnorm(c(159.5,200.5), 200, 10))
[1] 0.5199132


The plot below shows the binomial distribution (vertical bars) and the approximating normal distribution (blue curve). Vertical broken lines enclose the desired probability.

Note1: (1) Notice that the binomial probability $P(X = 200)$ is approximated by the normal probability $P(199.5 < X < 200.5),$ so if you use 200 as the upper boundary, you are losing about half of the probability of this one binomial value.

(2) Here the normal approximation (with continuity correction) is accurate to four places because (a) $n=400$ is relatively large and (b) $p = 1/2,$ for a symmetrical distribution. If $n$ is smaller or $p$ is far from $1/2,$ it is typical for the normal approximation to give only about two places of accuracy. For example, if $Y \sim \mathsf{Binom}(36, 1/3),$ then $P(5 \le Y \le 9) = 0.1875,$ but the normal approximation with continuity correction is $0.1844$ (or something like $0.1854,$ rounding to use printed normal tables).

pbinom(9, 36, 1/3) - pbinom(4, 36, 1/3)
[1] 0.1874903
diff(pnorm(c(4.5, 9.5), 12, sqrt(8)))
[1] 0.1843746

• Thank you for your explanation BruceET it's very interesting, btw I've not heard about the continuity correction factor in my classes nor four/two places. Aren't you being too formal with this? Would it be wrong if one doesn't use continuity correction factor in an exercise? – user441848 Apr 28 '18 at 2:56
• Depends on whether you want a normal approx. that is as close as possible to correct or whether you are satisfied with a very rough (partially incorrect) result. In terms of binomial $X,$ the probabilities $P(160 \le X \le 200)$ and $P(159.5 < X < 200.5)$ are exactly the same. The latter is more gracefully approximated by normal; what is the objection to using it? (@farruhota's Answer provides an excellent example.) // In a course, do what your instructor says. – BruceET Apr 28 '18 at 4:08
• There are several 'rules of thumb' that seek to describe when binomial $n$ and $p$ are suitable for normal approximation. One is that both $np$ and $n(1-p)$ should exceed 5. Another is that $np/(1 - p)$ and $n(1-p)/p$ should both exceed 3. There are better, more complicated rules, but those are the ones often seen in elementary texts. – BruceET Apr 28 '18 at 4:21
• Alrigth, thank you! – user441848 Apr 28 '18 at 18:07

Note that the binomial probability distribution is a discrete probability distribution, while normal probability distribution is a continuous probability distribution.

When the binomial probability distribution is approximated (under certain conditions) with the normal probability distribution, so called continuity correction factor should be applied. Refer to the graph below (source: wikipedia):

$\hspace{6cm}$

For example: $$P(1\le \underbrace{X}_{\text{binomial rv}}\le 4) = P(1-0.5\le \underbrace{X}_{\text{normal rv}}\le 4+0.5)=\\ P\left(\frac{(1-0.5)-np}{\sqrt{npq}}\le \underbrace{Z}_{\text{st.normal rv}}\le \frac{(4+0.5)-np}{\sqrt{npq}}\right),$$ because:

$\hspace{2cm}$

• Thank you for your explanation, it's very helpful :) I didn't know about it, I don't recall my teacher has mentioned this continuity correction factor but it make sense. – user441848 Apr 28 '18 at 1:27