Sub topic 3
How much data is enough: sample size and power
This chapter assumes you know DMAIC, can read a p-value, and have Python with numpy, scipy, and statsmodels installed.
Sample size and power
Power is the probability that a test detects a real difference of a given size. Four inputs set the sample size: the smallest effect that matters, the significance level alpha (usually 0.05), the power target (usually 0.80), and the variation in the data. Smaller effects need more data.
from statsmodels.stats.power import TTestIndPower
# Standardized effect of 0.8 (a large shift), alpha 0.05, power 0.80
n = TTestIndPower().solve_power(effect_size=0.8, alpha=0.05, power=0.80)
print(f"Units needed per group: {n:.0f}")> The effect size must be chosen before you collect data. Picking it after seeing the results biases the test.
Quantifying relationships with correlation and regression
The correlation coefficient r runs from -1 to 1 and measures how tightly two variables move together. Simple regression fits a line, y = a + bx, that predicts the output from one input.
import numpy as np
temperature = np.array([20, 22, 24, 26, 28, 30, 32])
defects = np.array([3, 4, 4, 6, 7, 8, 10])
r = np.corrcoef(temperature, defects)[0, 1]
slope, intercept = np.polyfit(temperature, defects, 1)
print(f"r = {r:.2f}, slope = {slope:.2f}, intercept = {intercept:.2f}")Correlation is not causation
A confounder is a third variable that drives both the suspected cause and the output. A strong correlation can have several explanations:
| Pattern | Possible meaning | Next step |
|---|---|---|
| X and Y correlate | X causes Y, or a confounder drives both | Check for a third factor |
| Correlation disappears within each shift | Shift was the confounder | Stratify and retest |
| Correlation holds within every group | Stronger case for causation | Confirm with a trial |
Confirming with a controlled trial or designed experiment
A controlled trial changes the suspected cause on purpose and randomly assigns units to the old and new settings. Randomization spreads confounders evenly across the groups, so differences in output point to the cause.
Recording the evidence and deciding what happens next
Record the hypothesis, sample size, p-value, effect size, and any confounders checked. Then decide:
- Accept the root cause when the trial reproduces the effect.
- Reject it when the effect disappears under controlled conditions.
- Revise it when the data points to a related cause.
Exercise
You want to detect a 0.5 standardized difference in cycle time with 80% power at alpha 0.05. Should you expect to need more or fewer units per group than the 0.8 example above?
Show answer
More. A smaller effect is harder to detect, so the test needs more units per group.