Binomial confidence interval

Public conversation · 10/8/2025, 4:40:17 AM

Started by kylecoelho97

#confidence intervals

You

Someone told me that to be 99% sure about something with 95% confidence with a binomial distribution, you need to do 300 trials and all should be successes.

9/29/2025, 4:05:16 AM

Branching Minds

What that person told you is a rule of thumb, but let’s check the math carefully.


The setup

You want to estimate the probability of success pp in a Bernoulli/binomial process. You run nn trials and observe kk successes. Here, they are saying:

  • n=300n = 300
  • k=300k = 300 (all successes)
  • You want to be 95% confident that the true success probability pp is at least 99%.

Using the Clopper–Pearson (exact) interval

For binomial confidence intervals, when k=nk = n, the lower bound of the 95% confidence interval is given by:

Lower bound=(1α)1/n\text{Lower bound} = (1 - \alpha)^{1/n}

where α=0.05\alpha = 0.05 for 95% confidence.

So with n=300n = 300:

Lower bound=(0.05)1/300\text{Lower bound} = (0.05)^{1/300}

Numerically:

(0.05)1/3000.9901(0.05)^{1/300} \approx 0.9901

So the 95% confidence interval is about:

0.9901, , 1.0


Interpretation

  • With 300 successes in 300 trials, you can say with 95% confidence that the true success rate is at least ~99.01%.
  • This matches the claim: 300 all-successes is just enough to cross the “99% at 95% confidence” threshold.

✅ The statement is basically correct.
If you had fewer trials (say 200), the lower bound would fall below 0.99. If you had more, the bound would be tighter.


Do you want me to also show you a general formula or Python snippet you can use to compute the minimum nn required for arbitrary thresholds (like 99.9% at 99% confidence)?

9/29/2025, 4:05:16 AM

You

What about 100 trials

9/29/2025, 4:05:50 AM

Branching Minds

Let’s run the same calculation for n=100n = 100 and all 100 are successes.


Formula (lower Clopper–Pearson bound when k=nk=n)

Lower bound=(1α)1/n\text{Lower bound} = (1 - \alpha)^{1/n}

with α=0.05\alpha = 0.05 for 95% confidence.

So:

Lower bound=(0.05)1/100\text{Lower bound} = (0.05)^{1/100}

Step-by-step calculation

  1. ln(0.05)2.9957\ln(0.05) \approx -2.9957
  2. Divide by 100 → 0.02996-0.02996
  3. Exponentiate → e0.029960.9705e^{-0.02996} \approx 0.9705

Result

With 100 successes in 100 trials, the 95% CI for pp is:

0.9705, , 1.0


Interpretation

  • You can only say with 95% confidence that the true success rate is at least 97.05%.
  • This is not enough to guarantee that p99%p \geq 99\%.

👉 So 100 trials, all successes, does not meet the “99% sure with 95% confidence” requirement. You need more trials — about 300, as you were told.

Want me to compute the exact minimum nn you’d need for the 99% lower bound at 95% confidence?

9/29/2025, 4:05:51 AM

You

Original custom instructions no longer available

10/8/2025, 4:53:15 AM

You

Is there a more sample efficient way of doing this?

10/8/2025, 5:34:13 AM

Branching Minds

There are more sample-efficient methods for estimating a proportion with a specified level of confidence. One common approach is using Wilson score interval or Agresti-Coull interval, which can provide narrower intervals compared to the Clopper-Pearson interval. These methods are quite popular in practice for their balance between accuracy and efficiency.

Would you like to delve deeper into how these methods work and how they can be applied in your scenario?

10/8/2025, 5:34:15 AM

Comments

No comments yet.

Add a comment