Sub topic 5
Rational subgroups: what goes in a sample
This chapter assumes you know what a control chart's center line and limits are, and that you can compute a mean and a range. It also assumes you know the difference between variables and attribute data. Basic NumPy is enough for the code.
What a rational subgroup is
A rational subgroup is a small set of measurements chosen so that two things hold:
- Variation inside the subgroup comes only from common causes, the steady background noise of the process.
- Any special cause that is present shows up as a difference between subgroups, not inside them.
The word "rational" refers to the reasoning you do before sampling. You decide what the chart should be able to detect, then collect data so that those changes land between subgroups.
This matters because of how control limits are computed. On an X-bar and R chart, the limits on the subgroup means come from R-bar, the average range within subgroups. The chart then asks whether the subgroup means differ by more than within-subgroup noise would explain. How you form subgroups therefore decides what counts as "noise" and what counts as a "signal".
How subgroup choice shapes the limits
Within-subgroup spread sets the width of the limits. Between-subgroup movement is what the chart tests against those limits.
- If a subgroup spans several sources of variation, the within-subgroup range grows. The limits widen, and real shifts hide inside the wider band.
- If a subgroup is so tightly clustered that it misses ordinary short-term variation, the range shrinks. The limits tighten, and ordinary drift triggers false alarms.
Neither failure produces an error message. The chart still draws, and only the interpretation is wrong.
Two common sampling strategies
| Strategy | How it works | Best at detecting | Weakness |
|---|---|---|---|
| Snapshot (instant) | Take n consecutive units at one moment, then wait until the next sampling time. | Shifts that persist from one sampling time to the next. | Misses a special cause that comes and goes between sampling times. |
| Period (spread) | Take n units spread across the interval since the last sample. | Intermittent problems, since the subgroup represents the whole interval. | The range includes any drift or shift within the interval, so the limits widen. |
Snapshot sampling is the default because it gives the cleanest estimate of short-term common-cause variation. Use period sampling when your main concern is a problem that appears and disappears between sample times. That choice is deliberate, because it lets the within-subgroup range absorb the intermittent variation.
Mixing streams: the most common mistake
A stream is any separate source of output: a machine, a cavity in a mold, an operator, a shift, a raw-material lot. Suppose two machines run at slightly different averages. If every subgroup contains units from both machines, the difference between machines is inside each subgroup. It inflates R-bar and widens the limits. Because every subgroup contains the same mix, the subgroup means look steady. The chart looks calm and says nothing about the machine difference.
The opposite grouping puts each subgroup on one machine. Then the machine difference appears between subgroups. The chart signals, and that is the correct result if the machine difference is a problem you want to find.
The code below shows both groupings on the same artificial data, with subgroup size 4. It uses fixed values instead of random numbers, so the results are reproducible. Machine A averages 10.0 and machine B averages 10.4.
import numpy as np
# Constants for subgroup size n = 4
A2, D3, D4 = 0.729, 0.0, 2.282
def xbar_r_limits(data):
"""Return subgroup means and the X-bar and R limits for rows of equal size."""
xbars = data.mean(axis=1)
ranges = data.max(axis=1) - data.min(axis=1)
xbarbar = xbars.mean()
rbar = ranges.mean()
limits = {
"xbar_lcl": xbarbar - A2 * rbar,
"xbar_center": xbarbar,
"xbar_ucl": xbarbar + A2 * rbar,
"rbar": rbar,
"r_ucl": D4 * rbar,
}
return xbars, limits
# A fixed pattern of short-term noise that rotates from one subgroup to the next
base = np.array([-0.10, 0.10, -0.05, 0.05])
noise = np.array([np.roll(base, k) for k in range(8)]) # 8 subgroups x 4 units
# Grouping 1: each subgroup comes from one machine; machines alternate A, B, A, B, ...
machine_mean = np.where(np.arange(8) % 2 == 0, 10.0, 10.4)
by_machine = machine_mean[:, None] + noise
# Grouping 2: every subgroup has two units from A and two from B
mixed = 10.2 + np.array([-0.2, -0.2, 0.2, 0.2]) + noise
for name, data in [("one machine per subgroup", by_machine),
("both machines in each subgroup", mixed)]:
xbars, lim = xbar_r_limits(data)
outside = int(np.sum((xbars > lim["xbar_ucl"]) | (xbars < lim["xbar_lcl"])))
print(name)
print(" X-bar limits:", round(lim["xbar_lcl"], 3), round(lim["xbar_center"], 3), round(lim["xbar_ucl"], 3))
print(" R-bar:", round(lim["rbar"], 3), " points outside X-bar limits:", outside, "of", len(xbars))Running it gives these results:
- With one machine per subgroup, R-bar is 0.2. The X-bar limits run from about 10.054 to 10.346, and all 8 subgroup means (10.0 and 10.4) fall outside them.
- With both machines in each subgroup, R-bar is about 0.55, almost three times larger. The X-bar limits widen to roughly 9.80 to 10.60, and no points fall outside them.
The machines differ in both cases. Only the first grouping lets the chart see the difference.
Stratify first, then decide what to chart
When you suspect several streams, the usual approach is:
- List the streams: machines, cavities, shifts, operators, material lots.
- Collect a small amount of data tagged by stream, then compare streams.
- If the streams behave the same, you may group across them. If they differ in a way you care about, chart each stream separately, or keep each subgroup within one stream.
- If a process has many parallel streams, such as a multi-cavity mold, consider charting one measurement per stream on a separate I-MR chart. A single combined chart hides which stream moved.
Do not average away a difference that you could have acted on.
Subgroup size and frequency
Two choices remain after you decide who belongs together.
Subgroup size n. For X-bar and R charts, n between 3 and 6 is typical, and 4 or 5 is the common default.
- A larger n makes the X-bar chart more sensitive to small shifts, because the standard error of the mean falls with the square root of n.
- A larger n also costs more, and it raises the risk that a subgroup spans more than one source of variation.
- The constants A2, D3, and D4 depend on n, so n should stay constant. Varying n means looking up constants for each subgroup, or using a chart based on standard deviation instead.
- At n of 1 there is no within-subgroup range, which is where the I-MR chart takes over.
Sampling frequency. Sample often enough that a special cause would show up before much output is affected. If process changes tend to occur every hour, sampling every four hours will often miss them. A common starting rule is to sample more often until you learn how fast the process changes, then reduce the frequency if the process proves stable.
Attribute charts. For p and u charts, the "subgroup" is the inspected lot or time period, and its size is set by the count of units or area inspected. The group should be large enough that you expect to see defects. A common guideline is an average of at least a few defects or defectives per subgroup. If the expected count is very low, most points sit on zero and the chart cannot detect improvement or deterioration. Combine periods or use a different method.
When rational subgroups do not exist
Sometimes there is no sensible way to form a group:
- Only one unit is made per batch, per day, or per month.
- Measurements are expensive or destructive.
- Units in a short run are so alike that repeated measurements only show measurement error.
In these cases, use an I-MR chart. Each individual value is its own subgroup, and the moving range between consecutive points stands in for the within-group estimate. The cost is that the chart relies more heavily on the data being roughly bell-shaped and free of autocorrelation, which a later chapter covers.
Checklist before you build a chart
- Do the units in a subgroup come from the same stream and the same short period?
- Would the special cause you care about appear between subgroups?
- Is n constant and appropriate for the chart type?
- Is the sampling interval short enough compared with how fast the process changes?
- For attribute data, is each subgroup big enough to expect some events?
Exercise
A plastic molding machine has four cavities, and cavity 3 runs about 0.3 mm larger than the others. An engineer forms each subgroup of 4 by measuring one part from each cavity, then builds an X-bar and R chart. The chart looks stable for weeks. Explain why the chart does not reveal the cavity 3 problem, and name one way to change the grouping so it would.
Show answer
Every subgroup contains one part from each cavity, so the cavity 3 offset is inside each subgroup. It enlarges the within-subgroup range, which raises R-bar and widens the limits. Because each subgroup has the same mix of cavities, the subgroup means stay steady and no point falls outside the wide limits. To reveal the problem, make each subgroup come from a single cavity, or chart each cavity on its own I-MR chart. The difference between cavities then appears between subgroups, where the chart can test it.
Exercise
A team inspects 20 invoices per day for errors and plots the proportion defective on a p chart. Most days show zero errors, and the chart is a flat line near zero. What is wrong with the subgroup choice, and what could the team change?
Show answer
The subgroup is too small for the defect rate. If errors occur in, say, 1 percent of invoices, 20 invoices give an expected 0.2 errors per subgroup, so most points are zero and the chart cannot show change. The team can inspect more invoices per period, for example pooling a full week so the expected count is several errors, or sample larger batches each day. They can also consider a different monitoring method for rare events.