The following quote about calculating a CI for a proportion:

To correct for the fact that we are approximating a discrete distribution with a continuous distribution (the normal distribution), we subtract 0.5/N from the lower limit and add 0.5/N to the upper limit of the interval.

Where (it appears) \(N\) is the sample size.

Another website:

http://stattrek.com/estimation/confidence-interval-proportion.aspx?Tutorial=AP

has the approximation simply as:

\(p \pm Z_{.95}\sqrt{\frac{p(1-p)}{n}}\)

Where \(n\) is the sample size.

The first approach can give values larger than 1 or smaller than 0. Here the vector has all 1s though it was possible to have gotten a zero. The result with te first formula above gives the following CI:

Code:

```
set.seed(10)
x <- sample(0:1, 100, TRUE, c(.001, .999))
[0.995, 1.005]
```

correct for the fact that we are approximating a discrete distribution with a continuous distribution

\(\pm \frac{.5}{N}\)