Skip to content

GQuality & process · doe.design

Design an experiment (factorial, screening, response surface, Latin hypercube)

Which runs should an experiment use, and in which order?

Builds a randomized run sheet: full factorials, fractional factorials with minimum-aberration generators and their alias structure, Plackett–Burman screening designs, central composite and Box–Behnken response-surface designs, or Latin hypercubes — with center points, replicates and blocks. Python and R build identical designs from the same generators and random stream.

Verified in Python and R Python and R agree to 10 decimals

A real result

Example “Full mixed”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Design an experiment (factorial, screening, response surface, Latin hypercube)Recorded · Python and R agreeRecorded 2026-11-17 · 15 values compared
R

A 2^3 full factorial design for 3 factors in 8 runs, randomized.

Factors
3
Runs
8
Blocks
1
Center points
0

Run sheet

RunStd orderPoint typeTemperaturePressureCatalyst
16factorial2001B
24factorial2003A
35factorial1501B
48factorial2003B
53factorial1503A
67factorial1503B
72factorial2001A
81factorial1501A
  • Standard order: the first factor changes fastest. Coded units: low = −1, high = +1.
Python

A 2^3 full factorial design for 3 factors in 8 runs, randomized.

Factors
3
Runs
8
Blocks
1
Center points
0

Run sheet

RunStd orderPoint typeTemperaturePressureCatalyst
16factorial2001B
24factorial2003A
35factorial1501B
48factorial2003B
53factorial1503A
67factorial1503B
72factorial2001A
81factorial1501A
  • Standard order: the first factor changes fastest. Coded units: low = −1, high = +1.

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

  • Full mixedNo data needed
  • Fraction res4 centreNo data needed
  • Fraction generatorsNo data needed
  • Plackett burman 11No data needed
  • Ccd blockedNo data needed
  • Ccd face 5No data needed
  • Box behnken 6No data needed
  • Lhs maximinNo data needed

In the guides

Where it sits in the decision guides

  • Statistical optimization (regression, response surface) · DS & ML Decision Guide · Optimize / decide

Choices you make

hypothesis

Factorsdefault Temperature: 150, 200; Pressure: 1, 3; Catalyst: A, B

One factor per line or separated by ';': “Name: low, high” for numeric factors, or “Name: a, b, c” for levels. The first value is the low (−1) setting.

Designdefault full_factorial

Which factor combinations are run: every combination, a fraction of them, a screening design, or a response-surface layout.

  • Full factorial(default) — Runs every combination of levels; estimates all effects, and the run count grows fast.
  • Fractional factorial (2^(k−p)) — Runs a chosen fraction of the two-level combinations; saves runs but confounds some effects.
  • Plackett–Burman screening — Screens many factors in few runs for main effects only; use it to narrow the list.
  • Central composite (response surface) — Adds center and axial points to a two-level design; fits curved surfaces and can build on an earlier factorial.
  • Box–Behnken (response surface) — Uses three levels without corner runs; fits curved surfaces when extreme combinations are unsafe or costly.
  • Latin hypercube (space filling) — Spreads runs evenly over each factor's range; pick it for computer experiments and flexible models.

options

Runsdefault —

Fractional factorials: the number of runs (a power of two; automatic = the smallest catalog fraction with the minimum resolution). Latin hypercubes: the number of points (automatic = 10).

Minimum resolutiondefault 4

III: main effects aliased with two-factor interactions; IV: main effects clear of two-factor interactions; V: two-factor interactions clear of each other.

Center pointsdefault —

Runs at the midpoint of every numeric factor (detect curvature, estimate pure error). Default: 4 for central composite, 3 for Box–Behnken, none otherwise.

Replicatesdefault 1

Repeat the whole design.

Run each replicate as a blockdefault off

Treat each replicate as a block, so day-to-day or batch differences don't blur the factor effects.

Axial pointsdefault circumscribed

Where axial points sit: beyond the cube (rotatable), at the limits (inscribed) or on the faces (three levels).

  • Circumscribed (rotatable, α = n_F^¼)(default) — Puts axial points beyond the cube so the design is rotatable; pick it when you can run settings past the factor limits.
  • Inscribed (axial points at the limits) — Scales the design so axial points sit at the limits; pick it when the limits are hard, accepting less range at the corners.
  • Face-centered (α = 1, three levels) — Puts axial points on the cube's faces, so each factor needs three levels; pick it when extra levels are hard to set.
Factorial and axial runs in separate blocksdefault off

Run the factorial and axial parts in separate blocks.

Latin hypercubedefault maximin

How points are placed in each cell of the Latin hypercube. Maximin spreads them out best.

  • Maximin (spread points out)(default) — Moves points within cells to maximize the smallest distance; the best spread, so the usual choice.
  • Random positions within cells — Places each point at random in its cell; quick, though points can bunch.
  • Cell centers — Places each point at its cell's center; gives tidy settings, with less variety between runs.
Randomize the run orderdefault on

Randomized within blocks with the analysis seed; the standard order is kept as a column.

Advanced

Generatorsdefault —

Override the catalog, e.g. “E=ABC, F=BCD” (letters skip I). Leave empty for the catalog design.

Maximin candidatesdefault 50

Number of random candidate designs compared when maximizing the minimum distance.

What it reports

k
How many groups, studies or clusters the analysis used. Many methods are less reliable when k is small.
runs
Counts runs above and below the median; too few or too many runs mean the order of the values isn't random.
n_blocks
How many independent units the analysis used; it sets precision and power.
design_label
The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
resolution
A subset of a factorial's runs that trades some interactions for far fewer runs; resolution says which effects get mixed up.
alpha
The false-positive rate you accept before looking at the data, usually 0.05.
generators
A subset of a factorial's runs that trades some interactions for far fewer runs; resolution says which effects get mixed up.
words
A subset of a factorial's runs that trades some interactions for far fewer runs; resolution says which effects get mixed up.
aliases
A subset of a factorial's runs that trades some interactions for far fewer runs; resolution says which effects get mixed up.
run_order
Assigning treatment by chance, which balances confounders, measured or not, on average.
point_type
Runs at the middle of every numeric factor, which test for curvature and estimate noise without changing the effect estimates.
block
Grouping observations that share a source (a subject, a batch) so their differences cancel out.
coded
One row per run in standard order, one column per factor, in coded units: −1 low, +1 high, 0 center.
n_center
Runs at the middle of every factor's range; they estimate pure error and reveal curvature.

Per group, level or term: resolution_roman

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-12). Python uses numpy, pandas, pyarrow, codesplash; R uses nanoparquet, codesplashr.

Default traps between the two languages

  • Both engines build designs with the same twin (generators, Plackett–Burman rows, Box–Behnken tables, Wichmann–Hill randomization), so run sheets are identical; FrF2/rsm/lhs are the classic R equivalents but order and randomize runs differently.
Python

The exact script CodeSplash ran for example “Full mixed” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Design an experiment (factorial, screening, response surface, Latin hypercube)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method doe.design 1.0.1 · spec e84f5b3035de5c3d
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import os

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.quality import design as doe  # twin of codesplashr::cs_doe_build (identical run sheets in R)

# Classic equivalent: pyDOE3 (ff2n / fracfact / pbdesign / ccdesign / bbdesign / lhs) — its row order and
# randomization differ, so the twin builds the design that both engines share.

# %% Design
factors = doe.parse_factors("Temperature: 150, 200; Pressure: 1, 3; Catalyst: A, B")
for f in factors:
    if f.name in doe.RESERVED:
        raise ValueError(f"“{f.name}” is a run-sheet column name; rename the factor.")
d = doe.build(
    factors,
    "full_factorial",
    runs=None,
    min_resolution=4,
    generators="",
    center_points=None,
    replicates=1,
    block_replicates=False,
    ccd_type="circumscribed",
    ccd_blocks=False,
    lhs_criterion="maximin",
    lhs_iterations=50,
    seed=42,
    randomize=True,
)
k = len(d.factors)
n_runs = d.coded.shape[0]
n_blocks = len(set(d.block))
n_center = sum(1 for t in d.point_type if t == "center")
actual = doe.actual(d)

# %% Run sheet (in run order) — written for the studio and for data entry
order = np.argsort(np.asarray(d.run_order), kind="stable")
sheet = pd.DataFrame({
    "Run": [d.run_order[i] for i in order],
    "Std order": [d.std_order[i] for i in order],
    "Block": [d.block[i] for i in order],
    "Point type": [d.point_type[i] for i in order],
})
for f, col in zip(d.factors, actual):
    sheet[f.name] = [col[i] for i in order]
out = "target/academy-parity/run-84541/doe.design/full-mixed/out-python" or os.environ.get("CS_OUT_DIR") or "outputs"
os.makedirs(out, exist_ok=True)
design_path = os.path.join(out, "design.parquet")
sheet.to_parquet(design_path, index=False)

# %% Result
warnings = list(d.notes)
shown = sheet.head(1000)
columns = [
    {"key": "run", "label": "Run", "type": "integer"},
    {"key": "std", "label": "Std order", "type": "integer"},
]
if n_blocks > 1:
    columns.append({"key": "block", "label": "Block", "type": "integer"})
columns.append({"key": "ptype", "label": "Point type", "type": "string"})
rows = []
for _, r in shown.iterrows():
    row = {"run": int(r["Run"]), "std": int(r["Std order"]), "block": int(r["Block"]), "ptype": r["Point type"]}
    for j, f in enumerate(d.factors):
        row[f"f{j}"] = r[f.name] if not f.numeric or isinstance(r[f.name], str) else float(r[f.name])
    rows.append(row)
for j, f in enumerate(d.factors):
    columns.append({"key": f"f{j}", "label": f.name, "type": "number" if f.numeric else "string"})
tables = [{"key": "runs", "title": "Run sheet", "columns": columns, "rows": rows,
           "note": None if len(sheet) <= 1000 else f"First 1,000 of {len(sheet):,} runs shown; the full sheet is in the design file."}]
if d.aliases:
    tables.append({
        "key": "aliases", "title": "Alias structure (main effects and two-factor interactions, up to three-factor aliases)",
        "columns": [{"key": "alias", "label": "Aliases", "type": "string"}],
        "rows": [{"alias": a} for a in d.aliases],
    })
if d.words:
    tables.append({
        "key": "defining", "title": "Defining relation",
        "columns": [{"key": "word", "label": "Word", "type": "string"}, {"key": "length", "label": "Length", "type": "integer"}],
        "rows": [{"word": "I = " + w, "length": len(w)} for w in d.words],
    })
charts = []
if k >= 2 and d.kind in ("ccd", "box_behnken", "lhs"):
    charts.append(cs.chart(
        "space", "scatter", f"Design points: {d.factors[0].name} × {d.factors[1].name} (coded)",
        {"x": cs.col(f"{d.factors[0].name} (coded)", d.coded[:, 0].tolist()),
         "y": cs.col(f"{d.factors[1].name} (coded)", d.coded[:, 1].tolist()),
         "color": cs.col("Point type", list(d.point_type), "categorical")},
        controls={"fit": "none"},
    ))
roman = doe.ROMAN.get(d.resolution) if d.resolution else None
values = {
    "k": k, "runs": n_runs, "n_blocks": n_blocks, "n_center": n_center, "design_label": d.label,
    "resolution": d.resolution, "resolution_roman": roman, "alpha": d.alpha,
    "generators": list(d.generators), "words": list(d.words), "aliases": list(d.aliases),
    "run_order": list(d.run_order), "point_type": list(d.point_type), "block": list(d.block),
    "coded": d.coded.tolist(),
}
summary = f"{d.label} for {k} factor{'s' if k != 1 else ''} in {n_runs} runs"
if d.resolution:
    summary += f" (resolution {roman})"
summary += ", randomized" if True else ", in standard order"
if n_blocks > 1:
    summary += f" in {n_blocks} blocks"
summary += "."
cs.publish({
    "title": "Design an experiment (factorial, screening, response surface, Latin hypercube)",
    "engine": cs.engine_info("numpy", "pandas"),
    "summary": summary,
    "statistics": [
        {"key": "k", "label": "Factors", "value": k, "format": "integer"},
        {"key": "runs", "label": "Runs", "value": n_runs, "format": "integer"},
        {"key": "n_blocks", "label": "Blocks", "value": n_blocks, "format": "integer"},
        {"key": "n_center", "label": "Center points", "value": n_center, "format": "integer"},
    ] + ([{"key": "resolution", "label": "Resolution", "value": d.resolution, "format": "integer"}] if d.resolution else []),
    "tables": tables,
    "charts": charts,
    "warnings": warnings,
    "notes": ["Standard order: the first factor changes fastest. Coded units: low = −1, high = +1."],
    "values": values,
    "artifacts": [{"key": "design", "path": design_path, "format": "parquet", "title": "Run sheet"}],
})
R

The exact script CodeSplash ran for example “Full mixed” · R version 4.5.1 (2025-06-13)

# Design an experiment (factorial, screening, response surface, Latin hypercube)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method doe.design 1.0.1 · spec e84f5b3035de5c3d
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_doe_build(): twin of codesplash.quality.design (identical run sheets in Python)

# Classic equivalents: FrF2::FrF2(), FrF2::pb(), rsm::ccd(), rsm::bbd(), lhs::maximinLHS() — they order and
# randomize runs differently, so the twin builds the design that both engines share.

# %% Design
factors <- cs_doe_parse_factors("Temperature: 150, 200; Pressure: 1, 3; Catalyst: A, B")
reserved <- c("Run", "Std order", "Block", "Point type")
for (f in factors) if (f$name %in% reserved) stop(sprintf("“%s” is a run-sheet column name; rename the factor.", f$name), call. = FALSE)
d <- cs_doe_build(
  factors, "full_factorial",
  runs = NULL,
  min_resolution = 4,
  generators = "",
  center_points = NULL,
  replicates = 1,
  block_replicates = FALSE,
  ccd_type = "circumscribed",
  ccd_blocks = FALSE,
  lhs_criterion = "maximin",
  lhs_iterations = 50,
  seed = 42,
  randomize = TRUE
)
k <- length(d$factors)
n_runs <- nrow(d$coded)
n_blocks <- length(unique(d$block))
n_center <- sum(d$point_type == "center")
actual <- cs_doe_actual(d)

# %% Run sheet (in run order) — written for the studio and for data entry
ord <- order(d$run_order, method = "radix")
sheet <- data.frame(Run = d$run_order[ord], `Std order` = d$std_order[ord], Block = d$block[ord],
                    `Point type` = d$point_type[ord], check.names = FALSE, stringsAsFactors = FALSE)
for (j in seq_len(k)) sheet[[d$factors[[j]]$name]] <- actual[[j]][ord]
out <- "target/academy-parity/run-84541/doe.design/full-mixed/out-r"
if (is.null(out)) out <- if (nzchar(Sys.getenv("CS_OUT_DIR"))) Sys.getenv("CS_OUT_DIR") else "outputs"
dir.create(out, recursive = TRUE, showWarnings = FALSE)
design_path <- file.path(out, "design.parquet")
nanoparquet::write_parquet(sheet, design_path)

# %% Result
warnings <- as.list(d$notes)
shown <- utils::head(sheet, 1000)
columns <- list(list(key = "run", label = "Run", type = "integer"), list(key = "std", label = "Std order", type = "integer"))
if (n_blocks > 1) columns[[length(columns) + 1]] <- list(key = "block", label = "Block", type = "integer")
columns[[length(columns) + 1]] <- list(key = "ptype", label = "Point type", type = "string")
for (j in seq_len(k)) columns[[length(columns) + 1]] <- list(key = paste0("f", j - 1), label = d$factors[[j]]$name,
                                                         type = if (d$factors[[j]]$numeric) "number" else "string")
rows <- lapply(seq_len(nrow(shown)), function(i) {
  row <- list(run = shown$Run[i], std = shown$`Std order`[i], block = shown$Block[i], ptype = shown$`Point type`[i])
  for (j in seq_len(k)) row[[paste0("f", j - 1)]] <- shown[[d$factors[[j]]$name]][i]
  row
})
tables <- list(list(key = "runs", title = "Run sheet", columns = columns, rows = rows,
                    note = if (nrow(sheet) <= 1000) NULL else sprintf("First 1,000 of %s runs shown; the full sheet is in the design file.", format(nrow(sheet), big.mark = ","))))
if (length(d$aliases)) tables[[length(tables) + 1]] <- list(
  key = "aliases", title = "Alias structure (main effects and two-factor interactions, up to three-factor aliases)",
  columns = list(list(key = "alias", label = "Aliases", type = "string")),
  rows = lapply(d$aliases, function(a) list(alias = a)))
if (length(d$words)) tables[[length(tables) + 1]] <- list(
  key = "defining", title = "Defining relation",
  columns = list(list(key = "word", label = "Word", type = "string"), list(key = "length", label = "Length", type = "integer")),
  rows = lapply(d$words, function(w) list(word = paste("I =", w), length = nchar(w))))
charts <- list()
if (k >= 2 && d$kind %in% c("ccd", "box_behnken", "lhs")) {
  charts[[1]] <- cs_chart(
    "space", "scatter", sprintf("Design points: %s × %s (coded)", d$factors[[1]]$name, d$factors[[2]]$name),
    list(x = cs_col(paste(d$factors[[1]]$name, "(coded)"), d$coded[, 1]),
         y = cs_col(paste(d$factors[[2]]$name, "(coded)"), d$coded[, 2]),
         color = cs_col("Point type", d$point_type, "categorical")),
    controls = list(fit = "none"))
}
roman <- cs_doe_roman(d$resolution)
values <- list(
  k = k, runs = n_runs, n_blocks = n_blocks, n_center = n_center, design_label = d$label,
  resolution = d$resolution, resolution_roman = roman, alpha = d$alpha,
  generators = I(d$generators), words = I(d$words), aliases = I(d$aliases),
  run_order = I(d$run_order), point_type = I(d$point_type), block = I(d$block),
  coded = d$coded
)
summary <- sprintf("%s for %d factor%s in %d runs", d$label, k, if (k != 1) "s" else "", n_runs)
if (!is.na(d$resolution)) summary <- paste0(summary, sprintf(" (resolution %s)", roman))
summary <- paste0(summary, if (TRUE) ", randomized" else ", in standard order")
if (n_blocks > 1) summary <- paste0(summary, sprintf(" in %d blocks", n_blocks))
summary <- paste0(summary, ".")
stats_list <- list(list(key = "k", label = "Factors", value = k, format = "integer"),
                   list(key = "runs", label = "Runs", value = n_runs, format = "integer"),
                   list(key = "n_blocks", label = "Blocks", value = n_blocks, format = "integer"),
                   list(key = "n_center", label = "Center points", value = n_center, format = "integer"))
if (!is.na(d$resolution)) stats_list[[length(stats_list) + 1]] <- list(key = "resolution", label = "Resolution", value = d$resolution, format = "integer")
cs_publish(list(
  method = "doe.design",
  methodVersion = "1.0.1",
  title = "Design an experiment (factorial, screening, response surface, Latin hypercube)",
  engine = cs_engine_info("codesplashr", "nanoparquet"),
  summary = summary,
  statistics = stats_list,
  tables = tables,
  charts = charts,
  warnings = warnings,
  notes = list("Standard order: the first factor changes fastest. Coded units: low = −1, high = +1."),
  values = values,
  artifacts = list(list(key = "design", path = design_path, format = "parquet", title = "Run sheet"))
))

Sources

  • Montgomery, D. C. (2017). Design and analysis of experiments (9th ed.). Wiley. Table 8.14.
  • Plackett, R. L., & Burman, J. P. (1946). The design of optimum multifactorial experiments. Biometrika, 33, 305–325.
  • Box, G. E. P., & Behnken, D. W. (1960). Some new three level designs for the study of quantitative variables. Technometrics, 2, 455–475.
  • McKay, M. D., Beckman, R. J., & Conover, W. J. (1979). A comparison of three methods for selecting values of input variables. Technometrics, 21, 239–245.

From the CodeSplash method registry · doe.design v1.0.1.