7 min read · Machine vision

A team tests a vision inspection system on 50 defective pieces. The system catches all of them and misses none. A manager asks, so it is ready to use, right? The answer is that we cannot say yet, because 50 pieces is too few to show that the miss rate is really low. This article explains why in plain language and says how many pieces to test. The examples in this article are hypothetical.
Missing nothing does not mean a miss rate of zero
Think of a die that we do not know is fair. Rolling it 5 times without getting a 6 does not mean the die has no 6. It was rolled too few times. An inspection system is the same. If it is tested on few defective pieces and happens to catch them all, the real miss rate may still not be low. You may just have been lucky this time.
The rule of three, in simple terms
The rule of three is a rough way to estimate the result when a test finds no misses. If you test on n defective pieces in total and the system catches every one, you can say the true miss rate is probably no higher than about 3 divided by n, at roughly 95 percent confidence.
Example: test 50 defective pieces and miss none. The true miss rate could still be as high as 3 divided by 50, which is 0.06 or 6 percent. That is higher than most people would consider acceptable. The n in this formula is the number of defective pieces tested, not the total number of pieces that went through the system, because the system only has a chance to miss on defective pieces.
To claim fewer misses than a target, how many defective pieces do you need?
Turn the same formula around. If you want the ceiling on the miss rate to be below a target, you need at least about 3 divided by the target in defective pieces, and the system must catch every one of them.
| Target miss rate | Defective pieces to test (approx.) | Condition |
|---|---|---|
| Below 5 percent | 60 pieces | Catches every piece |
| Below 2 percent | 150 pieces | Catches every piece |
| Below 1 percent | 300 pieces | Catches every piece |
| Below 0.5 percent | 600 pieces | Catches every piece |
These figures are estimates from the rule of three at roughly 95 percent confidence. If the system misses even one piece in the test set, the figures change and need a more careful calculation. For example, if it misses 2 of 50, the range of possible true miss rates is wide, from about 1.1 to 13.5 percent, calculated with a Wilson confidence interval. See the article on good parts rejected and defects slipping through for more detail.
Defects are rare, so you have to go and find them
If the plant has only 2 percent defects, sampling 50 pieces from the line has about a 36 percent chance of containing no defective piece at all (0.98 to the power of 50). To get 300 defective pieces by pure random sampling you would have to sample about 15,000 pieces, which takes a long time. So teams usually collect defective pieces in advance, for example from the reject bin, from pieces customers returned, or by deliberately creating samples.
But a hand-picked set has a downside. It tends to contain obvious defects and does not cover every type, so the result looks better than reality. You should also keep a separate set sampled from the real line, to see how the system performs on what is actually produced.
The good side needs testing too
Catching defects is only half the story. The other half is good parts rejected unnecessarily (false rejects). This side is easier, because good pieces are easy to find and plentiful, so you can comfortably test hundreds or thousands. The same principle applies: if you test 300 good pieces and none is rejected, the false-reject rate is probably no higher than about 1 percent.
Test with broad coverage
- Cover several shifts, several days and several lots of raw material.
- Cover every type of defect actually seen, not one type repeated.
- Cover a range of defect sizes, from obvious to very small ones near the threshold.
- Cover the lighting and temperature conditions as they change over time.
- Keep the test set separate from the set used to teach the AI. Do not let the same piece be in both.
- Have an experienced judge confirm which pieces are really defective before counting them as ground truth.
Common mistakes
- Drawing a conclusion from a test on few pieces and reporting that nothing was missed.
- Testing with pieces that were used to teach the AI, so the result looks better than it should.
- Testing only the clear-cut defects.
- Using the total number of pieces that passed through the system as n, when only the defective pieces should be counted.
- Testing once on a single day and treating it as valid forever.
- Not setting in advance how many misses are acceptable, then interpreting the result after seeing the numbers.
Hypothetical example: set the target before testing
Suppose the quality team at a plastic parts plant sets a target that the system’s miss rate should be below 2 percent. By the rule of three, that needs about 150 defective pieces, all caught. The team collects 150 defective pieces from several lots and several defect types, including small ones near the threshold. When run through the system, it misses 1 piece.
With 1 miss, the rule of three no longer applies directly. So the team asks a statistics specialist or the quality department to calculate the confidence interval, and looks at what kind of defect the missed piece had. If it was a very small type, the fix may be better lighting or more training examples, followed by a new round of testing on a separate set that was never used. The team does not decide pass or fail from a single number. They look at it together with the good-side results, the sample from the real line, and the risk of each defect type.
Limits and cautions
The rule of three is a rough estimate that assumes each defective piece is independent and representative of real defects. If the test set is not representative, the numbers will look better than reality. This article is not statistical or legal advice and does not set the pass criteria for any plant. The target miss rate must be set by the quality department and the responsible people according to the damage and risk of the product. For safety-related defects, have a specialist help design the test. The figures in the examples, such as 150 pieces and 1 miss, are all hypothetical.
Starting references
- Wikipedia — Rule of three (statistics)
- Wikipedia — Binomial proportion confidence interval
- Wikipedia — Sample size determination
- Google — Classification: accuracy, precision, recall




