ANALYSIS / 013OFFLINE
Power and sample size
How many parts to measure: power and sample size for t-tests, proportions and one-way ANOVA, and the sample size of a capability study for a Cpk confidence bound.
1-sample t · input
Runs in this browser. Data is not uploaded or stored.
1-sample t · results
—
2-sample t · input
Runs in this browser. Data is not uploaded or stored.
2-sample t · results
—
Paired t · input
Runs in this browser. Data is not uploaded or stored.
Paired t · results
—
1 proportion · input
Runs in this browser. Data is not uploaded or stored.
1 proportion · results
—
2 proportions · input
Runs in this browser. Data is not uploaded or stored.
2 proportions · results
—
One-way ANOVA · input
Runs in this browser. Data is not uploaded or stored.
One-way ANOVA · results
—
Capability study · input
Runs in this browser. Data is not uploaded or stored.
Capability study · results
—
Method
- Seven calculators on one page: the “Calculator” switch shows one of them. Each keeps its own fields and results; the settings file saves all of them and the chosen one. These are field calculators: there is no data to paste, so file import does not apply here. Exports are the results CSV and the settings JSON.
- Specify any two (as Minitab’s Power and Sample Size): of sample sizes, differences (or proportions) and power values, fill in two and leave the third empty; it is calculated for every combination of the others (up to 10 values per field, separated by spaces or semicolons, since a comma can be a decimal sign). A sample size is the smallest whole number whose power reaches the target; its actual power is shown too, as Minitab does. A difference is solved to full precision. A decimal comma in the fields gives decimal commas in the results and “;” in the CSV.
- Power is the probability that the test finds the difference when it is really there. 0.8 is a common minimum, 0.9 a safer choice. Power equals α when there is no difference; a sample size can therefore never be found for a difference of 0 or one in the direction the alternative excludes (the table says so).
- 1-sample t and paired t: exact power from the noncentral t distribution with n − 1 degrees of freedom and noncentrality δ = d √n / σ. Two-sided: P(T > t₁₋α/₂) + P(T < −t₁₋α/₂); “>”: P(T > t₁₋α); “<”: P(T < −t₁₋α). The paired t is the 1-sample t on the differences First − Second, so σ is the standard deviation of the differences (usually much smaller than that of the values when the pairing removes part-to-part variation).
- 2-sample t: n in each sample and the same σ in both (Minitab’s assumption for planning); 2n − 2 degrees of freedom, δ = d / (σ √(2/n)). Unequal σ or sample sizes are not offered.
- Noncentral t and F are written here without libraries: Poisson mixtures of incomplete beta functions, summed from the largest term outwards (Guenther 1978; Lenth’s AS 243 with the improvement of Benton & Krishnamoorthy 2003). They match scipy.stats.nct and scipy.stats.ncf to 1e-9 relative (1e-12 absolute) at several hundred points.
- 1 proportion (Minitab’s formula, normal approximation): with σ₀ = √(p₀(1 − p₀)/n) and σ₁ = √(p(1 − p)/n), power = Φ((p − p₀ − z₁₋α σ₀)/σ₁) for “>”, Φ((p₀ − p − z₁₋α σ₀)/σ₁) for “<”, and the sum of both with z₁₋α/₂ for ≠. This reproduces Minitab’s published example to every printed digit (p₀ 0.065: 0.431131, 0.764259, 0.449114, 0.703796). It is not the power of the exact binomial test, whose power jumps up and down with n (a “saw tooth”): for the same example the equal-tailed exact test (at most α/2 in each tail) gives 0.427, 0.758, 0.367, 0.649 and the arcsine approximation (statsmodels) 0.504, 0.795, 0.398, 0.672. When n · p is below 5 the page warns that the approximation is rough.
- 2 proportions (Minitab’s formula): n in each sample, σ₀ = √(2 p̄(1 − p̄)/n) with p̄ = (p₁ + p₂)/2, σ₁ = √((p₁(1 − p₁) + p₂(1 − p₂))/n), the same power formula with p₁ − p₂. Solving for the comparison proportion gives the value above and the one below the baseline for ≠ (Minitab’s example, baseline 0.6, n 1000, power 0.9: 0.669724 and 0.528190, reproduced here).
- One-way ANOVA: k levels with n values each; power from the noncentral F distribution with k − 1 and k(n − 1) degrees of freedom and λ = n Δ² / (2σ²), Δ the maximum difference between two means. This λ belongs to the least favourable means with that range (two means Δ apart, the others midway), so the power is the least the design gives, as Minitab defines it (its example, k 4, σ 1.64, power 0.9: Δ = 4.42404, 3.58435, 3.09574 for n = 5, 7, 9).
- Power curve: power against the difference (or the comparison proportion), one line per sample size of the table (at most six; the lines differ by dash pattern), with the table values as circles and the line of no difference, where the power equals α.
- Capability study: how many values a Cpk / Ppk or Cp / Pp study needs. The interval is the one the analysis would report when the estimate comes out exactly at the planned index. Cpk and Ppk: Bissell’s approximation Ĉ ± z √(1/(9n) + Ĉ²/(2(n − 1))), the formula of the Cpk tool (shared code); Cp and Pp: the exact chi-square interval Ĉ √(χ²_(α/2; n−1)/(n − 1)) to Ĉ √(χ²_(1−α/2; n−1)/(n − 1)). A lower bound uses z₁₋α or χ²_(α) (one-sided). Example: to show Cpk ≥ 1.33 with 95% confidence when the process runs at Cpk 1.67, 37 values are needed (lower bound 1.334); a ±0.1 interval for Cpk 1.33 takes 384 values. Solving for the planned index gives the estimate a study of n values must reach.
- Effective n in a capability study: the table assumes n individual values and σ with n − 1 degrees of freedom: the overall σ (Ppk, Pp), or the Cpk from one column, whose moving-range σ the Cpk tool counts with N − 1 moving ranges. With subgroups the within σ has ν = Σ(nᵢ − 1) degrees of freedom (25 subgroups of 5: N = 125, ν = 100) and the Cpk interval is somewhat wider for the same N. Values that are not independent (taken minutes apart from a drifting process) carry less information than their number suggests. And since the estimate varies from study to study, a process exactly at the planned Cpk misses the requirement in about half of the studies: plan with a margin.
- Checks: every result is compared with an independent Python script (scipy.stats nct, ncf, t, f, norm and chi2, sample sizes by a plain upward scan, differences by brentq), which also checks itself against statsmodels’ TTestPower, TTestIndPower and FTestAnovaPower, for 21 power cases (all three solve modes, one- and two-sided, other α) and 10 capability cases. Minitab’s published examples (1-sample t: n 26, power 0.904254; 2-sample t: n 86, power 0.903230; 1 proportion, 2 proportions and one-way ANOVA as above) and the textbook values (2-sample t, d/σ = 1, power 0.8: 17 per group; 1-sample t, d/σ = 0.5: 34) are reproduced.
- Examples: illustrative planning values, not data from a real plant: a fill weight against its target, wall thickness of two suppliers, boards in two fixtures, a defective rate before and after, two lines, four machines and a Cpk study. Exports mark a calculator as an example while its fields are unchanged.