Sub topic 4
Variables data and attribute data
This chapter assumes you know the mean, range, and standard deviation, and what a process and its output measurements are. Basic probability for proportions and counts helps but is not required. The Python examples use NumPy.
The first decision in choosing a control chart is what kind of data you have. The chart's formulas, its assumptions, and how much it can tell you all follow from that choice. This chapter explains the two data types, the two kinds of attribute data, and the habits that prevent a wrong choice. The later chapters build the individual charts.
Two families of data
Variables data (also called continuous or measurement data) comes from measuring something on a scale. Examples are length in millimeters, fill weight in grams, cycle time in minutes, and temperature in degrees. Between any two readings, a finer instrument could in principle report a value. The measurements are limited only by gauge resolution.
Attribute data (also called discrete or count data) comes from counting or classifying. Examples are the number of rejected units in a lot, the number of scratches on a panel, and the number of late deliveries this week. Values are whole numbers, and a fraction of a defect has no meaning.
| Question you ask | Data type | Typical values |
|---|---|---|
| How long is this part? | Variables | 10.07 mm |
| How long did the call last? | Variables | 6.4 min |
| Did this part pass or fail? | Attribute | pass / fail |
| How many flaws does this part have? | Attribute | 0, 1, 2, 3 ... |
The same process can produce both. A machined shaft has a diameter (variables). It can also be passed or failed against a drawing (attribute). The type depends on how you record the observation, not on the thing you observe.
Why the distinction matters for control charts
Control charts compare observed variation with the variation expected from common causes. The model of that expected variation differs by data type.
- Variables data has a location (the mean) and a spread (the standard deviation) that can change independently. A process can drift without getting noisier, or get noisier without drifting. Two quantities need monitoring, so variables charts come in pairs: one chart for the center and one for the spread. I-MR and X-bar and R both follow this pattern.
- Attribute data comes from counting, and the spread of a count is tied to its average. If the average rate of defects rises, the scatter rises with it. A single chart is enough, and the limits come from a probability model for counts, not from a measured range.
This is why the p chart and u chart have no companion range chart. Their limits come from the average level alone. It is also why their limits change with the sample size, as you will see in the chapters on those charts.
Two kinds of attribute data
Attribute data splits again, and this split is the most common source of mistakes. It separates the p chart from the u chart.
- A defective (also called a nonconforming unit) is a whole item that fails. Each item is either defective or not. You count items, and the count cannot exceed the number inspected.
- A defect (also called a nonconformity) is an individual flaw. One item can have several defects. Counts can exceed the number of items inspected.
Consider ten circuit boards inspected for solder flaws. The counts below show how the two ideas diverge on the same inspection.
import numpy as np
# Number of solder flaws found on each of 10 boards
flaws = np.array([0, 2, 0, 1, 0, 0, 3, 0, 1, 0])
boards = flaws.size
defective_boards = np.count_nonzero(flaws) # boards with at least one flaw
total_defects = flaws.sum()
print("Boards inspected:", boards)
print("Defective boards:", defective_boards)
print("Total defects:", total_defects)
print("Proportion defective (p):", defective_boards / boards)
print("Defects per unit (u):", total_defects / boards)This prints 10 boards, 4 defective boards, 7 defects, a proportion defective of 0.4, and 0.7 defects per unit. The proportion cannot be greater than 1. The defects per unit can be, for example when a very flawed board has 12 flaws.
The two probability models behind these counts are:
| Row | Defectives | Defects |
|---|---|---|
| Counted per | Item (pass or fail) | Flaw |
| Upper bound on the count | Number inspected, n | None in principle |
| Underlying model | Binomial | Poisson |
| Chart in this tutorial | p chart | u chart |
| Reported as | Proportion | Rate per unit |
The binomial model fits when each of n items independently has the same probability of failing. The Poisson model fits when flaws occur at random across a continuous region or period, and the count has no natural upper limit.
The area of opportunity
For defects, the amount of "room" for a flaw to appear is called the area of opportunity. It might be one board, 20 square meters of fabric, 1,000 lines of code, or a week of operation. If the area of opportunity differs between samples, raw counts are not comparable. Ten flaws on a small panel and ten flaws on a large panel mean different things. Dividing by the area of opportunity gives a rate that you can compare, and that is what the u chart plots.
For defectives the matching idea is the subgroup size n, the number of items inspected in each period. When n changes from period to period, the proportion defective is still comparable, but its natural scatter shrinks as n grows. The p chart handles this with limits that vary by period.
The choice between I-MR and X-bar and R also depends on how you form subgroups, which a later chapter covers. For now, notice that the first branch of the path is the data type.
Information lost when you convert
You can turn variables data into attribute data by checking each measurement against a limit and recording only pass or fail. This is what a go/no-go gauge does. It is fast and cheap, but it discards information. A measurement of 10.45 and one of 10.05 are both "pass", yet one sits close to the limit.
The following example makes this concrete. Two batches of ten parts have a specification of 9.5 to 10.5. The second batch has drifted upward by 0.15.
import numpy as np
lsl, usl = 9.5, 10.5
batch_a = np.array([10.2, 9.8, 10.1, 10.4, 9.9, 10.0, 10.3, 9.7, 10.1, 10.2])
batch_b = batch_a + 0.15 # the process has drifted upward
for name, batch in [("A", batch_a), ("B", batch_b)]:
out_of_spec = np.count_nonzero((batch < lsl) | (batch > usl))
print(f"Batch {name}: mean = {batch.mean():.2f}, "
f"out of spec = {out_of_spec} of {batch.size}")The output is a mean of 10.07 with 0 of 10 out of spec for batch A, and a mean of 10.22 with 1 of 10 out of spec for batch B. The measurements show a clear upward shift in the mean. The pass/fail record shows 0 and then 1 rejected part, which is easy to dismiss as chance. With only ten parts, one rejection says almost nothing. The same drift is visible in the measurements.
The practical consequences are:
- Variables charts detect a given shift with fewer observations than attribute charts, because each observation carries more information.
- Attribute charts need larger samples, because most samples will contain few or no defectives when the process is good.
- If you already measure a characteristic, plot the measurement. Reduce it to pass/fail only when no measurement exists, or when the characteristic really is a classification (for example, a label is present or absent).
Borderline cases
Real data does not always fit cleanly. Watch for these.
- Counts that act like measurements. A count with a large average, such as the number of transactions per hour, often behaves close to continuous data. People often chart such counts with an I-MR chart. A count with a small average, such as 0, 1, or 2 incidents per week, is not continuous, and an I-MR chart on it gives limits that make little sense (for example, a lower limit below zero).
- Ratings on a scale. A 1-to-5 satisfaction score is ordinal. Averages of such scores are sometimes charted, but the spacing between categories is not guaranteed to be equal. Treat the results with care.
- Rounded measurements. A gauge that reads to the nearest whole unit makes variables data look discrete. If the process spread covers only a few distinct gauge readings, the ranges and limits will be coarse. A rule of thumb is that the process spread should span at least about five to ten distinct values the gauge can report. Otherwise, you need a finer instrument.
- Percentages. A percentage can be a proportion of items (attribute, p chart) or a continuous ratio such as moisture content (variables). Ask what was counted before choosing a chart.
- Time between events. The days since the last incident is a measurement, even though the underlying events are counts. It is often charted as variables data when events are rare.
Checking your classification
Before drawing a chart, answer three questions in order.
- What exactly was recorded for each observation: a number from a scale, a pass/fail result, or a count of flaws?
- If it is a count, is the thing counted an item (defective) or a flaw (defect)?
- Is the sample size or area of opportunity constant across periods? If not, you need a chart that handles varying n.
Sample size and attribute charts
Attribute charts rely on counts being large enough to show variation. If the average defect rate is 1% and you inspect 20 items per period, you expect 0.2 defectives per sample. Most samples will show zero, and the chart will be a flat line broken by an occasional one. A common guideline is to choose n large enough that the expected number of defectives, n times the average proportion, is at least about 5, so that a typical sample contains a few. For defects, the equivalent guideline is an expected count per sample of at least about 5. These guidelines are approximate, and later chapters on the p and u charts return to them.
Exercise
A team inspects 50 invoices each day. They record the number of invoices with at least one error, and separately the total number of errors found across all 50 invoices. Which count is a defective count and which is a defect count? Which chart type fits each, and why can the total number of errors exceed 50 while the number of invoices with errors cannot?
Show answer
The number of invoices with at least one error is a defective count, because each invoice is either defective or not. Its upper bound is the 50 inspected, and it fits a p chart (binomial model). The total number of errors is a defect count, because it counts individual flaws, and one invoice can have several. It has no natural upper bound and fits a u chart (Poisson model), with the area of opportunity being one invoice, or the 50 invoices if you plot errors per invoice.
Exercise
A line records the fill volume of each bottle in milliliters and plots only whether it was inside the specification (pass/fail), as a proportion per hour. Name one advantage and one disadvantage of this choice compared with charting the volumes themselves.
Show answer
An advantage is that pass/fail needs no measurement system, so it is quick and cheap, and the p chart is simple to explain. The main disadvantage is lost information. A slow drift in mean volume stays hidden while every bottle remains in specification, and the chart signals only after bottles start failing. Because most samples contain no failures when the process is good, larger samples are needed. Charting the volumes (I-MR or X-bar and R) detects the drift sooner with smaller samples.