GQuality & process · spc.capability
Process capability (Cp, Cpk, Pp, Ppk, Cpm, PPM)
Can the process meet its specification limits?
Capability indices from within-subgroup variation (Cp, Cpk) and overall variation (Pp, Ppk), Cpm against a target, confidence intervals, and expected and observed parts per million outside the specifications — optionally after a Box–Cox transformation for skewed data.
A real result
Example “Pistonrings subgroups”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
Cpk = 1.54, Ppk = 1.35; about 25 parts per million expected outside the specifications.
- Cpk
- 1.536
- Ppk
- 1.355
- σ within
- 0.0101
- σ overall
- 0.0114
Plots
View data
| Normal (overall σ) | x | Diameter (mm) |
|---|---|---|
| 6.367e-6 | 73.940 | 74.030 |
| 8.533e-6 | 73.941 | 74.002 |
| 1.140e-5 | 73.941 | 74.019 |
| 1.520e-5 | 73.942 | 73.992 |
| 2.020e-5 | 73.942 | 74.008 |
| 2.677e-5 | 73.943 | 73.995 |
| 3.539e-5 | 73.944 | 73.992 |
| 4.664e-5 | 73.944 | 74.001 |
| 6.130e-5 | 73.945 | 74.011 |
| 8.034e-5 | 73.945 | 74.004 |
| 0.0001 | 73.946 | 73.988 |
| 0.0001 | 73.947 | 74.024 |
| 0.0002 | 73.947 | 74.021 |
| 0.0002 | 73.948 | 74.005 |
| 0.0003 | 73.948 | 74.002 |
| 0.0004 | 73.949 | 74.002 |
| 0.0005 | 73.950 | 73.996 |
| 0.0006 | 73.950 | 73.993 |
| 0.0008 | 73.951 | 74.015 |
| 0.0010 | 73.951 | 74.009 |
| 0.0013 | 73.952 | 73.992 |
| 0.0017 | 73.953 | 74.007 |
| 0.0021 | 73.953 | 74.015 |
| 0.0026 | 73.954 | 73.989 |
| 0.0033 | 73.954 | 74.014 |
| 0.0042 | 73.955 | 74.009 |
| 0.0052 | 73.956 | 73.994 |
| 0.0065 | 73.956 | 73.997 |
| 0.0081 | 73.957 | 73.985 |
| 0.0100 | 73.957 | 73.993 |
| 0.0124 | 73.958 | 73.995 |
| 0.0152 | 73.959 | 74.006 |
| 0.0187 | 73.959 | 73.994 |
| 0.0230 | 73.960 | 74 |
| 0.0281 | 73.961 | 74.005 |
| 0.0342 | 73.961 | 73.985 |
| 0.0416 | 73.962 | 74.003 |
| 0.0504 | 73.962 | 73.993 |
| 0.0610 | 73.963 | 74.015 |
| 0.0735 | 73.964 | 73.988 |
| 0.0884 | 73.964 | 74.008 |
| 0.1059 | 73.965 | 73.995 |
| 0.1266 | 73.965 | 74.009 |
| 0.1509 | 73.966 | 74.005 |
| 0.1794 | 73.967 | 74.004 |
| 0.2127 | 73.967 | 73.998 |
| 0.2514 | 73.968 | 74 |
| 0.2964 | 73.968 | 73.990 |
| 0.3484 | 73.969 | 74.007 |
| 0.4084 | 73.970 | 73.995 |
| 0.4775 | 73.970 | 73.994 |
| 0.5566 | 73.971 | 73.998 |
| 0.6470 | 73.971 | 73.994 |
| 0.7501 | 73.972 | 73.995 |
| 0.8671 | 73.973 | 73.990 |
| 0.9997 | 73.973 | 74.004 |
| 1.149 | 73.974 | 74 |
| 1.317 | 73.974 | 74.007 |
| 1.506 | 73.975 | 74 |
| 1.717 | 73.976 | 73.996 |
First 60 of 200 rows.
Capability indices
| Index | Value | 95% CI lower | 95% CI upper |
|---|---|---|---|
| Cp (within) | 1.655 | 1.492 | 1.817 |
| Cpk (within) | 1.536 | 1.378 | 1.693 |
| Cpl | 1.774 | — | — |
| Cpu | 1.536 | — | — |
| Pp (overall) | 1.460 | 1.316 | 1.603 |
| Ppk (overall) | 1.355 | 1.214 | 1.495 |
| Ppl | 1.565 | — | — |
| Ppu | 1.355 | — | — |
| Cpm | 1.392 | — | — |
Parts per million outside the specifications
| Basis | PPM |
|---|---|
| Expected (within σ) | 2.095 |
| Expected (overall σ) | 25.490 |
| Observed | 0 |
- Within σ: mean(R / d2). Overall σ: sample SD.
- Cpk CI: Bissell (1990); Cp/Pp CI: χ².
Cpk = 1.54, Ppk = 1.35; about 25 parts per million expected outside the specifications.
- Cpk
- 1.536
- Ppk
- 1.355
- σ within
- 0.0101
- σ overall
- 0.0114
To keep this page light, the plots are shown once, under the R tab.
Capability indices
| Index | Value | 95% CI lower | 95% CI upper |
|---|---|---|---|
| Cp (within) | 1.655 | 1.492 | 1.817 |
| Cpk (within) | 1.536 | 1.378 | 1.693 |
| Cpl | 1.774 | — | — |
| Cpu | 1.536 | — | — |
| Pp (overall) | 1.460 | 1.316 | 1.603 |
| Ppk (overall) | 1.355 | 1.214 | 1.495 |
| Ppl | 1.565 | — | — |
| Ppu | 1.355 | — | — |
| Cpm | 1.392 | — | — |
Parts per million outside the specifications
| Basis | PPM |
|---|---|
| Expected (within σ) | 2.095 |
| Expected (overall σ) | 25.490 |
| Observed | 0 |
- Within σ: mean(R / d2). Overall σ: sample SD.
- Cpk CI: Bissell (1990); Cp/Pp CI: χ².
Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.
Worked examples in the app
- Pistonrings subgroupsq1_pistonrings · subgroup: Sample · value: Diameter (mm)
- Individuals one sidedq1_nile · value: Flow
- Boxcoxq1_nile · value: Flow
- Pooled subgroupsq1_pistonrings · value: Diameter (mm)
- Degenerate constantq1_pistonrings · subgroup: Sample · value: Diameter (mm)
- Degenerate n1q1_pistonrings · subgroup: Sample · value: Diameter (mm)
In the guides
Where it sits in the decision guides
- Statistical optimization (regression, response surface) · DS & ML Decision Guide · Optimize / decide
What you need
- Measurementnumeric · 1 column
- The measured characteristic, in production order.
- Subgroupcategorical / numeric / temporal · 0–1 column
- Rows with the same value form a subgroup; without one, the within σ comes from the moving range of individual values.
Choices you make
hypothesis
- Lower specification limit (LSL)default —
Lower specification limit. Leave empty for a one-sided upper specification.
- Upper specification limit (USL)default —
Upper specification limit. Leave empty for a one-sided lower specification.
- Targetdefault —
Needed for Cpm.
- Confidence leveldefault 0.95
How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.
options
- Subgroup size (consecutive rows)default —
Rows per rational subgroup, taken in order. Empty treats every row as an individual measurement.
- Within-subgroup σdefault auto
How within-subgroup variation is estimated for Cp and Cpk. Automatic matches the control chart.
- Automatic (R̄/d2 for subgroups, moving range for individuals)(default) — Uses R̄/d2 for subgroups and the moving range for individuals, matching the control chart; the usual choice.
- Mean range (R̄ / d2) — Estimates σ from the mean range; matches X̄–R charts and suits small subgroups.
- Mean SD (S̄ / c4) — Estimates σ from the mean SD; matches X̄–S charts and suits larger subgroups.
- Pooled SD — Pools the subgroup variances; the most efficient when subgroups vary in size.
assumptions
- Transformationdefault none
Transform skewed data with Box–Cox before computing capability (positive values only).
- None (normal data)(default) — Computes capability on the raw values; pick it when the data are close to normal.
- Box–Cox (positive skewed data) — Applies Box–Cox to the data and the spec limits first; pick it for positive, skewed data.
- Box–Cox λdefault —
Box–Cox λ. Leave empty to estimate it from the data.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
Normal process data
Shapiro–Wilk on the (transformed) values; indices and PPM assume a normal distribution.
Stable process
Check a control chart first — capability is only meaningful for a process in control.
What it reports
- n
- How many independent units the analysis used; it sets precision and power.
- mean
- The sum divided by the count; the balance point of the data, pulled by extreme values.
- sd_within
- The typical distance of values from their mean, in the data's own units.
- sd_overall
- The typical distance of values from their mean, in the data's own units.
- cp
- How the spread and center of a stable process compare with its specification limits.
- cpk
- How the spread and center of a stable process compare with its specification limits.
- pp
- How the spread and center of a stable process compare with its specification limits.
- ppk
- How the spread and center of a stable process compare with its specification limits.
- cpm
- How the spread and center of a stable process compare with its specification limits.
- cp_low
- A range of effect values compatible with your data at the chosen confidence level.
- cp_high
- A range of effect values compatible with your data at the chosen confidence level.
- cpk_low
- A range of effect values compatible with your data at the chosen confidence level.
- cpk_high
- A range of effect values compatible with your data at the chosen confidence level.
- ppm_within
- How the spread and center of a stable process compare with its specification limits.
- ppm_overall
- How the spread and center of a stable process compare with its specification limits.
- ppm_observed
- How the spread and center of a stable process compare with its specification limits.
- lambda
- Shrinks coefficients towards zero to reduce overfitting; lasso can drop predictors entirely.
- lambda_hat
- Re-expressing a variable (log, square root, ranks) to reduce skew or stabilize variance.
- ppm_overall_round
- Overall parts per million expected outside the specification limits, rounded for the summary.
Python and R
Python and R agree to 10 decimals (relative tolerance 1e-9). Python uses numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.
Default traps between the two languages
- Normal and χ² quantiles from scipy ↔ R; Shapiro–Wilk p from scipy ↔ shapiro.test (both Royston's algorithm, ~1e-9).
- Box–Cox λ̂ by the same golden-section search in both engines (MASS::boxcox / scipy.stats.boxcox_normmax use other optimizers); the likelihood is flat at its maximum, so λ̂ agrees to ~1e-8 and the transformation uses λ̂ rounded to 0.001 (Minitab also uses a rounded λ), which makes every index identical.
The exact script CodeSplash ran for example “Pistonrings subgroups” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Process capability (Cp, Cpk, Pp, Ppk, Cpm, PPM)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method spc.capability 1.0.1 · spec aa4ccbb51190e88f
# Dataset: q1_pistonrings (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import numpy as np
import pandas as pd
from scipy import stats
import codesplash as cs
from codesplash.errors import check_not_constant
from codesplash.quality import capability as cap # twin of codesplashr::cs_spc_capability (qcc conventions)
from codesplash.quality import spc
# Classic equivalent in R: qcc::process.capability(qcc(groups, type = "xbar"), spec.limits = c(LSL, USL)).
# %% Data
df = pd.read_parquet("tests/parity/fixtures/q1_pistonrings.parquet", columns=["Diameter (mm)", "Sample"])
n_input = len(df)
df = df.dropna(subset=["Diameter (mm)", "Sample"]) # listwise deletion over the analysis columns
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["Diameter (mm)", "Sample"]) # infinite values stop the run (registry/errors.yaml)
# %% Data and specifications
value_col = "Diameter (mm)"
subgroup_col = "Sample"
x_raw = df[value_col].to_numpy(dtype=float)
lsl, usl, target = 73.95, 74.05, 74
if lsl is None and usl is None:
raise ValueError("Set at least one specification limit (LSL or USL).")
if lsl is not None and usl is not None and usl <= lsl:
raise ValueError("USL must be above LSL.")
cs.check_rows(len(x_raw), 2, "A capability analysis") # the spread needs two values that differ (registry/errors.yaml)
check_not_constant(x_raw, value_col)
conf = 0.95
transform = "none"
lam = None
lam_hat = None
x = x_raw
spec = {"lsl": lsl, "usl": usl, "target": target}
if transform == "boxcox":
if np.any(x_raw <= 0) or any(v is not None and v <= 0 for v in spec.values()):
raise ValueError("Box–Cox needs positive values and positive specification limits.")
lam = None
if lam is None:
# λ maximizes a flat profile likelihood; like Minitab, use it rounded (here to 0.001) so the
# transformation — and every index — is identical in Python and R.
lam_hat = cap.boxcox_lambda(x_raw)
lam = float(np.floor(lam_hat * 1000 + 0.5) / 1000)
x = cap.boxcox(x_raw, lam)
spec = {k: (float(cap.boxcox(np.array([v]), lam)[0]) if v is not None else None) for k, v in spec.items()}
labels = [str(v) for v in df[subgroup_col]] if subgroup_col else None
groups, _ = spc.subgroups(x, labels, None)
sw, sw_method = cap.within_sigma(groups, "auto")
res = cap.indices(x, sw, spec["lsl"], spec["usl"], spec["target"], conf)
sw_p = float(stats.shapiro(x).pvalue) if 3 <= len(x) <= 5000 else float("nan")
# %% Tables and chart
def r(key, label):
lo, hi = res.get(f"{key}_low"), res.get(f"{key}_high")
return {"index": label, "value": res[key], "low": lo, "high": hi}
tables = [{
"key": "indices", "title": "Capability indices",
"columns": [{"key": "index", "label": "Index", "type": "string"}, {"key": "value", "label": "Value", "type": "number"},
{"key": "low", "label": f"{conf:.0%} CI lower", "type": "number"}, {"key": "high", "label": f"{conf:.0%} CI upper", "type": "number"}],
"rows": [r("cp", "Cp (within)"), r("cpk", "Cpk (within)"), {"index": "Cpl", "value": res["cpl"]}, {"index": "Cpu", "value": res["cpu"]},
r("pp", "Pp (overall)"), r("ppk", "Ppk (overall)"), {"index": "Ppl", "value": res["ppl"]}, {"index": "Ppu", "value": res["ppu"]},
{"index": "Cpm", "value": res["cpm"]}],
}, {
"key": "ppm", "title": "Parts per million outside the specifications",
"columns": [{"key": "basis", "label": "Basis", "type": "string"}, {"key": "ppm", "label": "PPM", "type": "number"}],
"rows": [{"basis": "Expected (within σ)", "ppm": res["ppm_within"]}, {"basis": "Expected (overall σ)", "ppm": res["ppm_overall"]},
{"basis": "Observed", "ppm": res["ppm_observed"]}],
}]
charts = []
if transform == "none":
lo_x = min([float(np.min(x))] + [v for v in (lsl, usl, target) if v is not None])
hi_x = max([float(np.max(x))] + [v for v in (lsl, usl, target) if v is not None])
pad = 0.1 * (hi_x - lo_x)
gx = np.linspace(lo_x - pad, hi_x + pad, 200)
charts.append(cs.chart(
"capability", "capability-histogram", f"Capability of {value_col}",
{"value": cs.col(value_col, x.tolist()),
"fit_x": cs.col("x", gx.tolist()),
"fit_density": cs.col("Normal (overall σ)", stats.norm.pdf(gx, res["mean"], res["sd_overall"]).tolist())},
controls={"lsl": lsl, "usl": usl, "target": target},
))
else:
charts.append(cs.chart(
"capability", "capability-histogram", f"Capability of {value_col} (Box–Cox, λ = {lam:.3f})",
{"value": cs.col(f"{value_col} (transformed)", x.tolist())},
controls={"lsl": spec["lsl"], "usl": spec["usl"], "target": spec["target"]},
))
# %% Result
values = {k: res[k] for k in ("n", "mean", "sd_within", "sd_overall", "cp", "cpk", "cpl", "cpu", "pp", "ppk", "ppl", "ppu", "cpm",
"cp_low", "cp_high", "cpk_low", "cpk_high", "pp_low", "pp_high", "ppk_low", "ppk_high",
"ppm_within", "ppm_overall", "ppm_observed")}
values.update({"lambda": lam, "lambda_hat": lam_hat, "sw_p": sw_p, "ppm_overall_round": round(res["ppm_overall"]), "n_subgroups": len(groups)})
warnings = list(warnings)
if np.isfinite(sw_p) and sw_p < 0.05:
warnings.append(f"The {'transformed ' if lam is not None else ''}values depart from normality (Shapiro–Wilk p = {sw_p:.3g}); expected PPM may be off — consider the Box–Cox option.")
summary = f"Cpk = {cs.fmt_num(res['cpk'], 2)}, Ppk = {cs.fmt_num(res['ppk'], 2)}" if np.isfinite(res["cpk"]) else "Capability"
summary += f"; about {round(res['ppm_overall']):,} parts per million expected outside the specifications."
cs.publish({
"title": "Process capability (Cp, Cpk, Pp, Ppk, Cpm, PPM)",
"engine": cs.engine_info("numpy", "scipy"),
"n": res["n"],
"summary": summary,
"statistics": [
{"key": "cpk", "label": "Cpk", "value": res["cpk"]}, {"key": "ppk", "label": "Ppk", "value": res["ppk"]},
{"key": "sd_within", "label": "σ within", "value": sw}, {"key": "sd_overall", "label": "σ overall", "value": res["sd_overall"]},
],
"tables": tables,
"charts": charts,
"warnings": warnings,
"notes": [f"Within σ: {sw_method}. Overall σ: sample SD.", "Cpk CI: Bissell (1990); Cp/Pp CI: χ²."]
+ ([f"Box–Cox λ = {lam:.4f}; data and specification limits transformed."] if lam is not None else []),
"values": values,
})
The exact script CodeSplash ran for example “Pistonrings subgroups” · R version 4.5.1 (2025-06-13)
# Process capability (Cp, Cpk, Pp, Ppk, Cpm, PPM)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method spc.capability 1.0.1 · spec aa4ccbb51190e88f
# Dataset: q1_pistonrings (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_spc_capability(): twin of codesplash.quality.capability (qcc conventions)
# Classic equivalent: q <- qcc::qcc(qcc::qcc.groups(x, sample), type = "xbar", plot = FALSE);
# qcc::process.capability(q, spec.limits = c(LSL, USL), target = T)
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/q1_pistonrings.parquet", col_select = c("Diameter (mm)", "Sample")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("Diameter (mm)", "Sample")]), , drop = FALSE] # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("Diameter (mm)", "Sample")) # infinite values stop the run (registry/errors.yaml)
# %% Data and specifications
value_col <- "Diameter (mm)"
subgroup_col <- "Sample"
x_raw <- as.numeric(df[[value_col]])
lsl <- 73.95; usl <- 74.05; target <- 74
if (is.null(lsl) && is.null(usl)) stop("Set at least one specification limit (LSL or USL).", call. = FALSE)
if (!is.null(lsl) && !is.null(usl) && usl <= lsl) stop("USL must be above LSL.", call. = FALSE)
cs_check_rows(length(x_raw), 2, "A capability analysis") # the spread needs two values that differ (registry/errors.yaml)
cs_check_not_constant(x_raw, value_col)
conf <- 0.95
transform <- "none"
lam <- NULL
lam_hat <- NULL
x <- x_raw
spec <- list(lsl = lsl, usl = usl, target = target)
if (transform == "boxcox") {
if (any(x_raw <= 0) || any(vapply(spec, function(v) !is.null(v) && v <= 0, TRUE)))
stop("Box–Cox needs positive values and positive specification limits.", call. = FALSE)
lam <- NULL
if (is.null(lam)) {
# lambda maximizes a flat profile likelihood; like Minitab, use it rounded (here to 0.001) so the
# transformation - and every index - is identical in R and Python.
lam_hat <- cs_spc_boxcox_lambda(x_raw)
lam <- floor(lam_hat * 1000 + 0.5) / 1000
}
x <- cs_spc_boxcox(x_raw, lam)
spec <- lapply(spec, function(v) if (!is.null(v)) cs_spc_boxcox(v, lam) else NULL)
}
labels <- if (!is.null(subgroup_col)) as.character(df[[subgroup_col]]) else NULL
groups <- cs_spc_subgroups(x, labels, NULL)$groups
ws <- cs_spc_within_sigma(groups, "auto")
res <- cs_spc_capability(x, ws$sigma, spec$lsl, spec$usl, spec$target, conf)
sw_p <- if (length(x) >= 3 && length(x) <= 5000) stats::shapiro.test(x)$p.value else NaN
# %% Tables and chart
ci_row <- function(key, label) list(index = label, value = res[[key]], low = res[[paste0(key, "_low")]], high = res[[paste0(key, "_high")]])
tables <- list(
list(key = "indices", title = "Capability indices",
columns = list(list(key = "index", label = "Index", type = "string"), list(key = "value", label = "Value", type = "number"),
list(key = "low", label = sprintf("%.0f%% CI lower", 100 * conf), type = "number"),
list(key = "high", label = sprintf("%.0f%% CI upper", 100 * conf), type = "number")),
rows = list(ci_row("cp", "Cp (within)"), ci_row("cpk", "Cpk (within)"), list(index = "Cpl", value = res$cpl), list(index = "Cpu", value = res$cpu),
ci_row("pp", "Pp (overall)"), ci_row("ppk", "Ppk (overall)"), list(index = "Ppl", value = res$ppl), list(index = "Ppu", value = res$ppu),
list(index = "Cpm", value = res$cpm))),
list(key = "ppm", title = "Parts per million outside the specifications",
columns = list(list(key = "basis", label = "Basis", type = "string"), list(key = "ppm", label = "PPM", type = "number")),
rows = list(list(basis = "Expected (within σ)", ppm = res$ppm_within), list(basis = "Expected (overall σ)", ppm = res$ppm_overall),
list(basis = "Observed", ppm = res$ppm_observed))))
specs <- Filter(Negate(is.null), list(lsl = lsl, usl = usl, target = target))
if (transform == "none") {
lo_x <- min(c(x, unlist(specs))); hi_x <- max(c(x, unlist(specs)))
pad <- 0.1 * (hi_x - lo_x)
gx <- seq(lo_x - pad, hi_x + pad, length.out = 200)
charts <- list(cs_chart(
"capability", "capability-histogram", sprintf("Capability of %s", value_col),
list(value = cs_col(value_col, x), fit_x = cs_col("x", gx), fit_density = cs_col("Normal (overall σ)", stats::dnorm(gx, res$mean, res$sd_overall))),
controls = list(lsl = lsl, usl = usl, target = target)))
} else {
charts <- list(cs_chart(
"capability", "capability-histogram", sprintf("Capability of %s (Box–Cox, λ = %.3f)", value_col, lam),
list(value = cs_col(paste(value_col, "(transformed)"), x)),
controls = list(lsl = spec$lsl, usl = spec$usl, target = spec$target)))
}
# %% Result
keys <- c("n", "mean", "sd_within", "sd_overall", "cp", "cpk", "cpl", "cpu", "pp", "ppk", "ppl", "ppu", "cpm",
"cp_low", "cp_high", "cpk_low", "cpk_high", "pp_low", "pp_high", "ppk_low", "ppk_high", "ppm_within", "ppm_overall", "ppm_observed")
values <- res[keys]
values["lambda"] <- list(lam) # keep the key when NULL (no transformation)
values["lambda_hat"] <- list(lam_hat)
values$sw_p <- sw_p
values$ppm_overall_round <- round(res$ppm_overall)
values$n_subgroups <- length(groups)
if (is.finite(sw_p) && sw_p < 0.05)
warnings <- c(warnings, sprintf("The %svalues depart from normality (Shapiro–Wilk p = %s); expected PPM may be off — consider the Box–Cox option.",
if (!is.null(lam)) "transformed " else "", format(signif(sw_p, 3))))
summary <- if (is.finite(res$cpk)) sprintf("Cpk = %s, Ppk = %s", cs_fmt_num(res$cpk, 2), cs_fmt_num(res$ppk, 2)) else "Capability"
summary <- paste0(summary, sprintf("; about %s parts per million expected outside the specifications.", format(round(res$ppm_overall), big.mark = ",")))
cs_publish(list(
method = "spc.capability",
methodVersion = "1.0.1",
title = "Process capability (Cp, Cpk, Pp, Ppk, Cpm, PPM)",
engine = cs_engine_info("stats", "codesplashr"),
n = res$n,
summary = summary,
statistics = list(list(key = "cpk", label = "Cpk", value = res$cpk), list(key = "ppk", label = "Ppk", value = res$ppk),
list(key = "sd_within", label = "σ within", value = ws$sigma), list(key = "sd_overall", label = "σ overall", value = res$sd_overall)),
tables = tables,
charts = charts,
warnings = warnings,
notes = c(sprintf("Within σ: %s. Overall σ: sample SD.", ws$method), "Cpk CI: Bissell (1990); Cp/Pp CI: χ².",
if (!is.null(lam)) sprintf("Box–Cox λ = %.4f; data and specification limits transformed.", lam)),
values = values
))
Sources
- Montgomery, D. C. (2013). Introduction to statistical quality control (7th ed.). Wiley. Chapter 8.
- Bissell, A. F. (1990). How reliable is your capability index? Applied Statistics, 39, 331–340.
- ISO 22514-2:2017. Statistical methods in process management — Capability and performance.
From the CodeSplash method registry · spc.capability v1.0.1.