experimental-design
/experimental-design
Use when planning a study before data collection: choosing a design, randomization, blocking or stratification, factorial or fractional-factorial DOE, crossover or repeated measures, cluster randomization, Latin squares, run order, or sequential designs.
- Author
- ymurat ↗
- Repository
- academic-agent-skills ↗
- Licence
- MIT
- Last repository change
- 07.11.2026
Assessment and security
- Files in this package
- 9
- Scripts
- 2
- HTML comments
- 0
- URLs in SKILL.md
- 4
No signals detected. Repository changed on 07.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 2 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/doe_designs.py, scripts/randomization.py
What it does and when to use it
Use when planning a study before data collection: choosing a design, randomization, blocking or stratification, factorial or fractional-factorial DOE, crossover or repeated measures, cluster randomization, Latin squares, run order, or sequential designs.
Original author description
Use when planning a study before data collection: choosing a design, randomization, blocking or stratification, factorial or fractional-factorial DOE, crossover or repeated measures, cluster randomization, Latin squares, run order, or sequential designs.
How it works
- Overview
- When to Use This Skill
- Installation
- Choosing a design
- Generating the design
- The mistakes that ruin studies
- Workflow
- Resources
- Software engineering examples
SKILL.md preview
---
name: experimental-design
description: Use when planning a study before data collection: choosing a design, randomization, blocking or stratification, factorial or fractional-factorial DOE, crossover or repeated measures, cluster randomization, Latin squares, run order, or sequential designs.
license: MIT
---
# Experimental Design
## Overview
The design of a study, how units are assigned to conditions, what is held constant, what is varied, and in what structure, determines what questions the data can answer. No analysis can rescue a confounded or pseudoreplicated design after the fact. This skill is about the decisions made *before* data collection: picking a design that isolates the effect of interest, randomizing to license causal claims, blocking to remove known nuisance variation, and structuring multi-factor experiments so effects are estimable rather than tangled together.
The three ideas behind almost every good design (Fisher's principles):
- **Randomization**: assign treatments at random so that confounders, known and unknown, are balanced in expectation. This is what turns a comparison into a causal claim.
- **Replication**: independent repetition at the right level, so you can estimate variability and your effects aren't artifacts of a single unit. The most common fatal error is **pseudoreplication**: counting repeated measurements on the same unit as independent replicates.
- **Blocking / local control**: group similar units (by batch, day, site, litter) and randomize within blocks, removing that nuisance variation from the error term instead of letting it inflate noise.
This skill helps you choose among design types, generate the actual randomization or DOE layout (with reproducible scripts), and avoid the structural mistakes that make data uninterpretable.
## When to Use This Skill
- Planning any comparative experiment or trial and deciding how to assign units
- Randomizing subjects/samples to arms (simple, blocked, stratified, or cluster)
- Removing nuisance variation by blocking or stratification
- Designing multi-factor experiments: full or fractional factorial, screening designs
- Optimizing a response over continuous factors (response-surface designs)
- Within-subject / repeated-measures, crossover, split-plot, or Latin-square designs
- Cluster- or group-randomized designs (sites, clinics, classrooms, litters)
- Deciding the number and level of replicates and avoiding pseudoreplication
- Sequential, group-sequential, or adaptive designs with interim analyses
- Laying out plates/batches and randomizing run order to defeat drift
## Installation
```bash
uv venv --python 3.13 .venv-design
uv pip install --python .venv-design/bin/python "numpy==2.5.3" "pandas==3.0.6" "pydoe==1.5.0"
```
`pyDOE3` was [archived in May 2026](https://github.com/relf/pyDOE3); active
development returned to [pydoe](https://pydoe.github.io/pydoe/). The bundled
wrappers target `pydoe==1.5.0`, imported as lowercase `pydoe`, and return
designs in real factor units. All seven DOE wrappers and both script demos were
executed with Python 3.13, NumPy 2.5.3, pandas 3.0.6, and SciPy 1.18.1. On
Windows, the environment interpreter is `.venv-design/Scripts/python.exe`.
Archive the environment versions and exported schedules: a seed alone does not
promise identical output across package or script upgrades.
---
## Choosing a design
Start from the question and the structure of your units, not from a favorite design.
```
What are you trying to learn?
│
├─ Compare a few predefined conditions (A vs B vs C)?
│ ├─ Units independent, possibly with a known nuisance factor (day, batch, site)?
│ │ → Completely randomized (no nuisance) or RANDOMIZED BLOCK design.
│ ├─ Each unit can receive every condition in sequence (washout possible)?
│ │ → CROSSOVER / repeated-measures design (watch carry-over and correlation).
│ └─ You can only randomize groups, not individuals (schools, clinics)?
│ → CLUSTER-randomized design (account for clustering; see pseudoreplication).
│
├─ Screen MANY factors (5+) to find the few that matter?
│ → FRACTIONAL FACTORIAL or PLACKETT-BURMAN screening design.
│
├─ Quantify main effects AND interactions among a handful of factors?
│ → FULL 2^k FACTORIAL design.
│
├─ Find the settings that OPTIMIZE a response (curvature matters)?
│ → RESPONSE-SURFACE design: central composite or Box-Behnken.
│
└─ Explore a simulation/computer model over a continuous space?
→ SPACE-FILLING design: Latin hypercube.
```
Detailed guidance per branch:
- **Randomization, blocking, stratification, controls** → `references/randomization_and_blocking.md`
- **Factorial, fractional-factorial, screening, response-surface, DOE concepts (aliasing, resolution)** → `references/factorial_and_doe.md`
- **Crossover, repeated-measures, split-plot, Latin-square, cluster, nested designs** → `references/design_types.md`
- **Sequential, group-sequential, and adaptive designs (interim analyses)** → `references/sequential_and_adaptive.md`
---
## Generating the design
Two scripts produce ready-to-use, reproducible layouts. Run them from the skill's
`scripts/` directory or add it to `sys.path`. Seeds support reproducible layouts
within the recorded software environment.
The default seed is for demonstrations; choose and securely record a study-specific
seed for a real allocation. These helpers do not implement an enrollment system
or conceal future assignments from recruiters.
### Randomization / allocation schedules, `scripts/randomization.py`
```python
from randomization import (
simple_randomization, block_randomization,
stratified_block_randomization, cluster_randomization,
assign_factorial_runs, arm_balance,
)
# Permuted blocks balance at completed-block boundaries.
# A partial final block or interim prefix need not have the requested ratio.
sched = block_randomization(n=60, arms=["treatment", "control"], seed=42)
# Balance a prognostic variable across arms by randomizing within each stratum
sched = stratified_block_randomization({"siteA": 30, "siteB": 30},
arms=["drug", "placebo"], ratio=(2, 1), seed=42)
# Randomize whole clusters, not individuals (the cluster is the unit)
sched = cluster_randomization(["clinic1", "clinic2", "clinic3", "clinic4"], seed=42)
arm_balance(sched) # sanity-check the counts per arm
sched.to_csv("allocation_schedule.csv", index=False)
```
Choosing among them: **simple** is fine for large n but can produce imbalance with
small n; **block** enforces the ratio within each complete block; **stratified block**
does this independently within each stratum; **cluster** is mandatory when the intervention
is delivered at a group level. See `references/randomization_and_blocking.md`.
For a sequence of stratum labels, `unit_id` is the original one-based input
position, including when strata are interleaved. Join the exported schedule to
your subject IDs using that position and verify every ID exactly once. A dict
input creates grouped planning slots rather than assigning an existing roster.
Missing stratum labels and duplicate cluster IDs are rejected.
### DOE matrices, `scripts/doe_designs.py`
```python
from doe_designs import (
full_factorial, two_level_factorial, fractional_factorial,
plackett_burman, central_composite, box_behnken, latin_hypercube,
)
# Factors as real-world (low, high) ranges -> design comes back in real units
factors = {"temp_C": (20, 60), "conc_mM": (1, 10), "pH": (6, 8)}
# Full 2^3: all main effects + all interactions (8 runs), run order randomized
design = two_level_factorial(factors, seed=42)
# Screen 7 factors cheaply (main effects only)
many = {f"factor_{i}": (0, 1) for i in range(7)}
design = plackett_burman(many, seed=42)
# Optimize over 2 factors with curvature (response-surface)
design = central_composite(
{"temp_C": (20, 60), "conc_mM": (1, 10)},
center=(2, 2), face="inscribed", seed=42,
)
design.to_csv("experimental_runs.csv", index=False)
```
Before running a central composite design, inspect each factor's actual minimum
and maximum. The default `face="circumscribed"` places axial points beyond the
supplied low/high factorial settings; those arguments are not hard operating
limits. If the stated ranges are physical limits, choose `face="inscribed"` or
`face="faced"`, then recheck all combinations. Do not clip out-of-range rows:
clipping changes the design geometry and its statistical properties. See the
[NIST CCD comparison](https://www.itl.nist.gov/div898/handbook/pri/section3/pri3361.htm).
The CCD example reserves four center runs; execute them independently to estimate
pure error. The wrapper default has only one. Confirm all settings are feasible, the intended
model matrix has full rank, and independent replication supplies residual degrees
of freedom. Center points check aggregate curvature; they do not identify each
quadratic term without axial or other suitable runs.
DOE run order is randomized by default (Latin hypercube defaults to no added
`run_order`) so factors are not systematically aligned with time/drift
(machine warm-up, reagent aging). See `references/factorial_and_doe.md` for picking
generators, reading the alias structure, and choosing resolution. These wrappers
shuffle globally: for split plots, plates, or a CCD run in separate batches, retain
block IDs and randomize only within the permitted structure.
---
## The mistakes that ruin studies
These are structural, they can't be fixed in analysis, only in design.
1. **Pseudoreplication.** Treating repeated measurements of one unit as independent
replicates: 3 mice with 100 cells each is n = 3 (mice), not n = 300 (cells), for
any treatment applied to the mouse. The replicate must be at the level the
treatment is randomized. This single error invalidates a large share of published
experiments. Randomize and replicate at the right level; analyze with the nesting
respected (mixed model). See `references/design_types.md`.
2. **Confounding by a nuisance variable.** Running all treatment samples on Monday
and all controls on Tuesday confounds treatment with day. Randomize across, or
block on, every nuisance factor you can name (batch, day, plate, technician,
instrument, position).
3. **No or broken randomization.** Convenience assignment (first-come → treatment)
lets confounders sneak in. Use a seeded schedule and follow it.
4. **No proper control.** Without a concurrent control (and, where relevant, a
vehicle/sham and blinding), you can't separate the treatment effect from time,
placebo, or handling effects.
5. **Batch effects mistaken for biology.** In omics especially, process samples in a
randomized/blocked order across batches; never let batch align with the condition.
6. **Edge/position effects on plates.** Evaporation and thermal gradients make plate
edges differ. Randomize or block sample positions; don't put all controls in
column 1.
7. **Aliasing ignored in fractional designs.** A low-resolution fractional factorial
confounds main effects with interactions; know your alias structure before
concluding a factor "has no effect."
8. **Optimizing without curvature.** A two-level factorial alone cannot estimate
pure quadratic terms; you'll miss an interior optimum. Use a response-surface design.
---
## Workflow
1. **State the question, the unit, and the response.** What is randomized? What is
measured? At what level is a true independent replicate? This determines everything.
2. **List nuisance factors** (batch, day, site, operator, position): plan to block,
stratify, or randomize across each.
3. **Pick the design** using the decision tree and reference files.
4. **Decide replication** at the correct level (and get n from the
**statistical-power** skill for the chosen design).
5. **Generate the layout** with `randomization.py` / `doe_designs.py`, seeded.
6. **Randomize run/processing order** and plate/batch positions within the design
restrictions; verify roster IDs, completed-block balance, range limits, and rank.
7. **Document** the design, software versions, seed, and schedule. Pre-specify the
analysis; restrict access to the seed and future assignments during enrollment.
8. **Match the analysis to the design**: blocks, strata, clusters, and nesting must
appear in the model (hand off to **se-stats** / **statsmodels**).
---
## Resources
### Scripts
- `scripts/randomization.py`: seeded allocation schedules: `simple_randomization`,
`block_randomization`, `stratified_block_randomization`, `cluster_randomization`,
`assign_factorial_runs`, `arm_balance`.
- `scripts/doe_designs.py`: DOE matrices in real units: `full_factorial`,
`two_level_factorial`, `fractional_factorial`, `plackett_burman`,
`central_composite`, `box_behnken`, `latin_hypercube`.
### References
- `references/randomization_and_blocking.md`: randomization methods, blocking,
stratification, controls, blinding, batch/plate layout.
- `references/factorial_and_doe.md`: factorial and fractional designs, resolution
and aliasing, screening, and response-surface methodology.
- `references/design_types.md`: completely randomized, randomized block, crossover,
repeated-measures, split-plot, Latin-square, cluster, and nested designs; the
pseudoreplication problem in depth.
- `references/sequential_and_adaptive.md`: group-sequential designs, alpha spending,
interim stopping, and adaptive sample-size re-estimation.
### Related skills
- **statistical-power**: required sample size / power for the design you've chosen.
- **se-stats**: running the test, effect sizes and reporting after data collection.
### Key references
- Fisher, R. A. (1935). *The Design of Experiments*.
- Montgomery, D. C. (2019). *Design and Analysis of Experiments* (10th ed.).
- Hurlbert, S. H. (1984). Pseudoreplication and the design of ecological field
experiments. *Ecological Monographs*, 54(2), 187–211.
- Lazic, S. E. (2016). *Experimental Design for Laboratory Biologists*.
## Software engineering examples
- **Tool or technique experiment with students:** randomize participants to treatment within blocks of prior experience (e.g. GPA band or pretest score); keep allocation concealed from the person recruiting.
- **Crossover with two tasks:** use an AB/BA design balanced over task order and task object to separate the treatment from learning and task effects (Vegas et al. 2016 warn about these confounds in SE crossovers).
- **Classroom as unit:** if whole sections get a teaching method, the section is the experimental unit; analyze as cluster-randomized, not per student (pseudoreplication).
- **LLM / prompt configuration screening:** factors such as model, temperature, prompt template, retrieval on/off, few-shot count; use a 2^(k-p) fractional factorial to screen, then a full factorial on the active factors. Treat benchmark items as a blocking or random factor and repeat runs for nondeterminism.
- **Performance benchmarking:** randomize run order, block by machine or day, include warm-up runs, and record environment as covariates.
- Report per ACM SIGSOFT Empirical Standards (see empirical-se-standards skill): unit, assignment method, blocking factors, threats to validity.
---
Adapted from [K-Dense-AI/scientific-agent-skills](https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/experimental-design), MIT License. Upstream promotion and citation-fetch instructions removed; SE examples added.
Files in this package (9)
- LICENSE-K-Dense 1 KB
- README.md 3 KB
- SKILL.md 15 KB
- references/design_types.md 8 KB
- references/factorial_and_doe.md 9 KB
- references/randomization_and_blocking.md 8 KB
- references/sequential_and_adaptive.md 6 KB
- scripts/doe_designs.py 9 KB
- scripts/randomization.py 9 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · ymurat/academic-agent-skills | 100 | MIT |
| synthetic-sciences/openscience | 100 | Apache-2.0 |
| PracticalSwan/agent-skills | 100 | MIT |
| K-Dense-AI/scientific-agent-skills | 100 | MIT |
| NEO849/a-team-2 | 100 | MIT |
| beita6969/scienceclaw | 100 | MIT |
| radarist/structured-analytic-skills | 100 | MIT |
| sandbaseai/sandbase-skills | 90 | Apache-2.0 |
| bestagentkits/agency-skills | 87 | MIT |
Database snapshot: 13.11.2026 · package version 5cefb4e02b19 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 95bio-experimental-design-randomization-blocking
Structures biological experiments so inference is valid by construction, covering Fisher's principles (randomization, replication, local control), the experimental-vs-observational unit distinction and pseudoreplication (Hurlbert 1984; Lazic 2018), randomization mechanics… - 100experiment-design
Design scientific experiments including sample size calculation, randomization, control groups, blinding, and study protocols. Covers RCTs, quasi-experiments, factorial designs, A/B tests, survey design, and observational studies. Use when user asks to design an experiment,… - 100doe-designer
Plan, generate, verify and analyse designed experiments (DOE) using the process-improve library. Use whenever the user wants to design an experiment, screen factors, optimise a process or formulation, build a response surface, choose a fractional factorial or Plackett-Burman or… - 100parameter-optimization
Explore and optimize simulation parameters via design of experiments (DOE), sensitivity analysis, and optimizer selection — generate Latin Hypercube, quasi-random, or factorial sample plans, rank parameter influence with sensitivity scores, recommend Bayesian optimization,… - 100experiment-design
Design scientific experiments including sample size calculation, randomization, control groups, blinding, and study protocols. Covers RCTs, quasi-experiments, factorial designs, A/B tests, survey design, and observational studies. Use when user asks to design an experiment, ca... - 100study-design
Design a research study. Use when the user says "study design", "design my research", "what research method should I use", "how do I test this hypothesis", "research plan", "methodology section", "experimental design", "survey design", "qualitative study design", "how to…