Continuity Correction
A normal random variable can approximate a binomial random variable





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