Sub topic 4
Computing Cumulative Percentages
Prerequisites and purpose
Assume you know how to tally events into categories, calculate basic percentages, and read a bar chart. Basic Python and pandas are needed only for the code examples.
A cumulative percentage shows how much of the total has been reached as categories are added in order. In a Pareto analysis, categories are usually ordered from largest to smallest. The cumulative percentage then answers this question:
> What share of all observations is covered by this category and every category before it?
This calculation creates the line used in a Pareto chart.
The calculation
Start with a frequency count for each category. A frequency is the number of observations in that category.
For each category:
- Add its count to the counts above it. This is the cumulative count.
- Divide the cumulative count by the total count.
- Multiply by 100 to express the result as a percentage.
The formula is:
\[ \text{cumulative percentage}k = \frac{\sum{i=1}^{k} \text{count}i} {\sum{i=1}^{n} \text{count}_i} \times 100 \]
The index \(k\) identifies the current position in the ordered list. The denominator remains the same for every row.
Consider these defect counts, sorted from largest to smallest:
| Defect category | Count | Cumulative count | Cumulative percentage |
|---|---|---|---|
| Scratches | 42 | 42 | 42.0% |
| Misalignment | 27 | 69 | 69.0% |
| Wrong label | 11 | 80 | 80.0% |
| Cracks | 8 | 88 | 88.0% |
| Other | 7 | 95 | 95.0% |
| Discoloration | 5 | 100 | 100.0% |
The total is 100 defects. After the first category, the cumulative share is 42%. After the first three categories, it is 80%. The final row must reach 100%, apart from small rounding differences.
Why order matters
Cumulative percentages depend on the order of the categories. Pareto charts use descending order because the purpose is to reveal the categories that account for the largest share first.
If you sort alphabetically, the cumulative line still calculates correctly, but it no longer highlights the largest contributors at the left side of the chart. A decision-maker might then miss the most useful starting point.
The total does not change when you reorder categories. The sequence of cumulative values does change.
Computing the values in pandas
The pandas cumsum method returns a running total. Dividing that running total by the sum of all counts produces the cumulative share.
import pandas as pd
defects = pd.Series({
"Scratches": 42,
"Misalignment": 27,
"Wrong label": 11,
"Cracks": 8,
"Discoloration": 5,
"Other": 7,
})
# Sort ordinary categories first. Keep the catch-all bucket last.
main = defects.drop("Other").sort_values(ascending=False)
data = pd.concat([main, defects[["Other"]]])
cumulative_pct = data.cumsum() / data.sum() * 100
result = pd.DataFrame({
"count": data,
"cumulative_pct": cumulative_pct.round(1),
})
print(result)A catch-all category such as Other needs care. It combines several causes, so it usually belongs at the end even if its count would place it elsewhere. This keeps the chart useful for investigation. If Other is large, split it into meaningful categories before deciding what to fix.
Finding the category that reaches a target
The 80% reference is a decision aid, not a requirement. To find the categories needed to reach a target, include the category that crosses the target line.
For example, if the cumulative values are 42%, 69%, and 80%, the vital few contain the first three categories. If the values are 42%, 69%, and 79%, the next category must also be included.
Exercise
Exercise
Counts are 50, 30, 15, and 5 in descending order. What is the cumulative percentage after the third category?
Show answer
The cumulative count is 95 and the total is 100, so the cumulative percentage is 95%.