Let’s say the results of software testing averaged three defects per 10,000 lines of code. The criteria for release is 90% probability of 5 or fewer defects per 10k lines.

If this product ready for release?

The Poisson distribution is appropriate here as it is useful for modeling defects per unit, count per area, or arrivals per hour. If the data, in this case, the defect count per lines of code to be modeled by the Poisson distribution, the probability of an occurrence (defect in this case) has to be proportional to the interval (lines of code in this case). Also, the number of occurrences (defects) per interval must be independent (more on statistical independence in another post).

The Poisson distribution is like the Exponential distribution in it has only one parameter. Â The mean and variance terms are equal. The probability density function represents the probability of exactly x occurrences in an interval having an average ofÂ Î¼ occurrences.

$$ \large\displaystyleÂ f(x)=\frac{{{e}^{-\mu }}{{\mu }^{x}}}{x!}$$

The cumulative distribution function is the sum of the probability density function.

$$ \large\displaystyleÂ F(x)=\sum\limits_{i=0}^{x}{\frac{{{e}^{-\mu }}{{\mu }^{i}}}{i!}}$$

Some references may have a table for the cumulative distribution and helps to avoid many calculations for each term in the summation.

Back to the example problem above. We need to calculate the probability of exactly 0, 1, 2, 3, 4 and 5 defects per 10k lines of code, then add those together to get the probability of 5 or fewer defects per 10k lines.

First, we need the estimate ofÂ Î¼ which is given as three defects per 10k lines. Now, we can start the calculations.

Defects, x | f(x) |

0 | 0.0498 |

1 | 0.1494 |

2 | 0.2240 |

3 | 0.2240 |

4 | 0.1680 |

5 | 0.1008 |

Summing the f(x) column we find 0.916. Which means given the test results showing an average defect rate of 3 per 10k lines of code, there is a 91.6% probability of actually having 5 or fewer defects per 10k lines of code.

The product meets the criteria for release.

Related:

The Poisson DistributionÂ (article)

The Exponential DistributionÂ (article)

OC Curve with Binomial MethodÂ (article)

Tim Adams says

Some may find it helpful if after first sentence in fourth paragraph (The Poisson distribution is like the Exponential distribution in it has only one parameter.) this was added, “In particular, the Exponential distribution is a special case of the Poisson distribution when x = 0.”