# Upper Confidence Limit for Defect Rate Calculator

> Source: https://netray.co/tools/defect-rate-upper-confidence-limit-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

You found 2 defects in 125 pieces. What is the highest defect rate the lot could plausibly have? This tool answers that.

## Category

quality

## Audience

- Quality engineer
- Supplier quality
- Incoming inspector

## Tool

**Kind:** calculator

**Inputs:**

#### Sample size n

**Key:** n

**Type:** number

**Default:** 125

**Min:** 1

**Step:** 1

**Unit:** pieces

#### Defectives found d

**Key:** d

**Type:** number

**Default:** 2

**Min:** 0

**Step:** 1

**Unit:** pieces

#### One-sided confidence level

**Key:** conf

**Type:** select

**Default:** 0.95

**Options:**

##### 90%

**Value:** 0.9

##### 95%

**Value:** 0.95

##### 99%

**Value:** 0.99

#### Lot size N

**Key:** lot_size

**Type:** number

**Default:** 5000

**Min:** 1

**Step:** 100

**Unit:** units

**Outputs:**

#### Observed defect rate

**Key:** phat

**Expr:** d / n * 100

**Format:** decimal

#### One-sided z

**Key:** z

**Expr:** normsinv(conf)

**Format:** decimal

#### Upper confidence limit on defect rate

**Key:** upper

**Expr:** ((d / n) + z*z / (2*n) + z * sqrt(((d / n) * (1 - d / n)) / n + z*z / (4*n*n))) / (1 + z*z / n) * 100

**Format:** decimal

**Primary:** true

**Description:** Wilson score bound in percent. You can say the true rate is below this value with the chosen confidence.

#### Upper limit in PPM

**Key:** ppm

**Expr:** upper * 10000

**Format:** integer

#### Worst-case defectives in the lot

**Key:** worst_lot

**Expr:** ceil(upper / 100 * lot_size)

**Format:** integer

**Primary:** true

#### Exact bound if d = 0

**Key:** zero_exact

**Expr:** (1 - pow(1 - conf, 1 / n)) * 100

**Format:** decimal

**Description:** Only meaningful when no defectives were found. For d above zero use the Wilson result.

**Chart:**

#### Upper confidence limit (%) vs sample size, same defects found

**Type:** line

**X:** n

**From:** 20

**To:** 1000

**Steps:** 40

**Series:**

- upper

**Disclaimer:** The Wilson score bound is an approximation that behaves well for small samples, but it is slightly less conservative than the exact Clopper-Pearson bound. Use exact methods for regulated claims.

## Content

**Intro:** A clean sample does not mean a clean lot. Finding zero or two defects in a sample only tells you the true rate is probably below some ceiling. This calculator computes that ceiling, so your acceptance or supplier claim says what the data really supports.

**Sections:**

#### How to use it

**Body:** Enter how many pieces you inspected, how many defectives you found, and the confidence you want, usually 95 percent. The tool returns the observed rate, the upper confidence limit, the same limit in PPM, and the worst-case number of defectives in a lot of your size. The chart holds your defect count and sweeps the sample size so you can see how much more inspection would tighten the answer.

**Bullets:**

- Use one-sided confidence when you only care about how bad the lot could be.
- Count each defective piece once, not each defect on a piece.
- Do not combine samples from different lots or conditions.

#### The math

**Body:** The Wilson score upper bound for a proportion is (p + z squared over 2n + z x sqrt(p(1 - p)/n + z squared over 4n squared)) divided by (1 + z squared over n), where p = d/n and z is the one-sided normal value. It works at d = 0, unlike the plain normal approximation that collapses to zero. For zero defects the exact bound is 1 - (1 - confidence) raised to 1/n, which gives the familiar rule of three: about 3 divided by n at 95 percent.

#### Worked example

**Body:** You inspect 125 pieces and find 2 defectives. The observed rate is 1.6 percent, but the 95 percent upper limit is about 4.7 percent. In a lot of 5000 that is up to roughly 236 defectives you cannot rule out. If you found none in 125, the exact bound is still about 2.4 percent. To demonstrate a limit below 1 percent with zero failures at 95 percent, you need about 299 pieces. The chart shows that returns diminish as the sample grows.

#### Common mistakes

**Body:** Treating the observed rate as the lot rate is the classic error. So is claiming 'zero defects' from a small clean sample. Another is applying the formula to non-random samples, such as the first pieces off a run, which do not represent the lot. The result is only as good as the randomness of the sample.

**Cta:** If you want supplier defect claims and acceptance decisions backed by confidence limits straight from your ERP data, we can set that up. Ask for a short review.

**Faq:**

#### What does the upper confidence limit mean?

**Answer:** It is a ceiling on the true defect rate. At 95 percent confidence, you can say that if the same procedure were repeated many times, the true rate would be below the computed limit in about 95 percent of the cases.

#### Why not just use the observed rate?

**Answer:** A sample is only a slice of the lot. The same lot can give different counts on a different sample. The upper limit allows for that sampling noise, which matters most when counts are small.

#### What is the rule of three?

**Answer:** When you find zero defects in n pieces, the 95 percent upper limit on the defect rate is about 3 divided by n. For example zero defects in 300 pieces means you can only claim the rate is below about 1 percent.

#### Is Wilson accurate enough?

**Answer:** For most inspection decisions, yes. It is close to exact and much better than the simple normal formula. For legal or regulated claims, use the exact Clopper-Pearson interval in a statistics package.

## Search terms

upper confidence limit defect rate, confidence interval defective rate, Wilson score upper bound, how bad could the lot be, zero defects in sample confidence, rule of three defects, sample defect rate to lot defect rate, binomial confidence limit calculator

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
