# Compute a confidence interval for Bernoulli distribution

Given a Bernoulli distribution with a success probability of p = 0.02. Let's say we have N=3000 samples. How can I compute a confidence intervals for the expected number of successes (e.g., with 5% significance level)?

• What parameter are we computing the confidence interval for? The expected number of successes is $Np = 60$ which is known with perfect confidence regardless of what the data (the outcomes of the $3000$ trials) happen to be. The actual number of successes that have occurred is available simply by counting the successes in the data and is also known with perfect confidence. If the $3000$ trials have not occurred as yet, and the question is to find the shortest interval $[a,b]$ such that $P\{a \leq X \leq b\} \geq 0.95$, then that is a question about probability, not about confidence intervals. – Dilip Sarwate Jan 28 '13 at 15:09
• @cbeleites No, it is no homework question but it is derived from a real scenario. Each day there are about 0.02x3000 = 60 hits. Whenever the actual number is lower than that (e.g., 50 hits), I immediately get several questions about it. I often answer that it could be natural fluctuation, but meanwhile I'm just curious about the mathematical background. – Philipp Claßen Jan 28 '13 at 16:11
• R's pbinom() tells me that you should expect 50 or fewer hits on about 10.5% of all days. Nothing to really pester you with questions about... – S. Kolassa - Reinstate Monica Jan 28 '13 at 19:40

Your expected value is $3000\times0.02=60$, the variance is $3000\times 0.02\times(1-0.02)=58.8$. Simulating 100,000 trials and plotting a histogram, I would say you can use the normal approximation unless you have very strong requirements on accuracy (in which case the R help page says that "qbinom() uses the Cornish-Fisher Expansion to include a skewness correction to a normal approximation, followed by a search", which may help).
nn <- 3000 