e-Mathematics > Probability and Statistics
for 3470-001 student.

Continuity Correction

A normal random variable can approximate a binomial random variable $ X$. Here a normal density function $ f(x)$ on the interval $ (k-0.5, k+0.5)$ is viewed approximately as the height of frequency function $ p(k)$. Then we can approximate the probability, say $ P(6 \le X \le 11)$, by the area under the curve on the interval $ (5.5,11.5)$.

n = 20
p = 0.5
intval = c(6,11)
nn = 0:n
pmf = dbinom(nn,n,p)
mean = n * p
sd = sqrt(n * p * (1-p))
x = seq(-0.5, n+0.5, length=100);
y = dnorm(x, mean, sd);
plot(x, y, type='l', lwd=2, frame.plot=F, main="Normal Approximation");
prob.mass(nn,pmf,lty=1)
nn = intval[1]:intval[2]
pmf = dbinom(nn,n,p)
prob.mass(nn,pmf,lty=1,col='yellow')
x = seq(intval[1]-0.5, intval[2]+0.5, length=50);
y = dnorm(x, mean, sd);
polygon(c(x,max(x),min(x)), c(y,0,0), lwd=2, col=2, density=20);
prob = pbinom(intval[2],n,p) - pbinom(intval[1]-1,n,p)
text(intval[1], pmf[1], pos=4, round(prob,digits=4))
prob = pnorm(intval[2]+0.5, mean, sd) - pnorm(intval[1]-0.5, mean, sd)
text(intval[1]-0.5, pmf[1], pos=2, col=2, round(prob,digits=4))

Sample R code. You can download ccorrection.R, and run it.

Example 1. Suppose that a coin is tossed 100 times and lands heads 60 times or more. Should we be surprised and doubt that the coin is fair?

Change the parameters in the above sample code, and find out the answer. Here the probability in red is obtained by normal approximation.

n = 100
p = 0.5
intval = c(60,100)


© TTU Mathematics