e-Statistics > 4480-5480 Probability and Statistics II

## Continuity Correction

When a random variable is discrete, its frequency function is viewed as the height of relative frequency histogram with interval . Then we can approximate its probability by the area under the curve.

Example. Suppose that has a binomial distribution with n = 15 and p = 0.3. We can find the probability on the interval "intval = c(2,7)." The exact probability (in black) and the normal approximation (in red) with continuity correction are shown in the display.

```n = 15
p = 0.3
intval = c(2,7)
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.hist(nn,pmf,lty=1)
nn = intval[1]:intval[2]
pmf = dbinom(nn,n,p)
prob.hist(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], pmf[1], pos=2, col=2, round(prob,digits=4))
```