Practice

Randomisation after class · 8–10 minutes

Gavin Simpson

Aarhus University

Wednesday, 21 October 2026

One design, many results

The design fixes:

  • 24 experimental units
  • four diet levels
  • six pens assigned to each diet
  • the random procedure

The seed selects one allocation from the allocations allowed by that design.

Seeds are not scores

treatments <- rep(
  c("Control", "Diet A", "Diet B", "Diet C"),
  each = 6
)

set.seed(123)
sample(treatments) |> head()
[1] "Diet B"  "Diet C"  "Diet B"  "Control" "Diet A"  "Diet B" 
set.seed(202)
sample(treatments) |> head()
[1] "Diet B"  "Diet B"  "Diet A"  "Diet C"  "Control" "Diet C" 

Different outputs can both be valid.

Chance imbalance

The seed-123 allocation had six pens per diet, but Diet C appeared in four Central-room pens.

That does not show that:

  • sample() failed
  • the allocation was non-random
  • the researcher should silently redraw

It shows that overall balance does not imply balance within every room.

Decide constraints first

Before generating an allocation, record:

  • the experimental unit
  • treatment replication
  • any scientifically justified blocks or restrictions
  • the random procedure
  • the checks that must pass

Then generate once, check, and retain the result.

Four records

Hand-drawn randomisation workspace showing pig-pen unit cards, coloured treatment cards, a random draw and a retained allocation record.

Reproducible means complete

Keeping only the seed is insufficient.

set.seed(123)

The same seed can produce a different result if:

  • the unit order changes
  • the treatment vector changes
  • another random operation occurs first
  • the code changes

Audit without redesigning

Check that:

  • each experimental unit appears once
  • treatment totals match the design
  • pre-specified restrictions are satisfied
  • no predictable non-random rule replaced the draw
  • the retained table matches what is implemented

An audit checks the planned rules; it does not invent new rules after seeing the result.

Read and reflect

Read Ruxton and Colegrave, Chapter 7, sections 7.1–7.4, pp. 101–108.

As you read, answer:

  1. What feature of random allocation limits researcher choice?
  2. Why can a random allocation contain imbalance?
  3. Which records would let another researcher audit your allocation?

Sources

Ruxton, Graeme D., and Nick Colegrave. 2016. Experimental Design for the Life Sciences. 4th ed. Oxford: Oxford University Press. Chapter 7, sections 7.1–7.4, pp. 101–108. ISBN 978-0-19-871735-5. Publisher page.

R Core Team. 2026. R: A Language and Environment for Statistical Computing. Vienna: R Foundation for Statistical Computing. R project.