Challenge your conclusionLesson 22 of 30 · 7 min

Let assignment generate the comparison

Run a paired randomisation test without breaking the experimental blocks.

In a paired randomised experiment, the order of A and B is chosen separately in each block. The sharp no-effect claim says that changing a label would leave each individual outcome unchanged. If that holds, swapping labels within each block gives the possible results of the assignment procedure.

SciPy’s samples permutation mode swaps the treatment labels while preserving pairs. The statistic here is mean⁡(B−A)\operatorname{mean}(B-A). We enumerate all assignments for these eight invented pairs: 28=2562^8=256 label patterns. This differs from shuffling all sixteen readings together.

This interpretation requires that the label swaps match how the experiment was assigned and that one treatment does not affect the next. An observational study would need its own reason for treating the two labels in each pair as exchangeable.

Swap labels inside the block

Original labels

A₁ = 80 · B₁ = 72

A₂ = 130 · B₂ = 119

Flip first pair

A₁ = 72 · B₁ = 80

A₂ = 130 · B₂ = 119

Each row remains the same block. Times in ms.

28=2562^8=256
Eight invented pairs generate 2⁸ = 256 within-pair label patterns under the stated null and assignment assumptions. This illustration flips the first pair only. No outcome is exchanged with a different block.

What information would be lost by shuffling all readings across all machines?

Write a prediction (optional)

Run the prepared example

This page puts the example in the Python editor. Select Run Python with the code unchanged.

Invented data

Editor tools
About Python ↗

Ctrl+Enter or ⌘+Enter runs the code.

What to compare

Find Exact assignment patterns and Two-sided permutation p-value. What stays together in every pattern, even when an A and a B label swap?

Published example output

The site ran the original code to produce this reference. Build environment ↗

Mean B-minus-A (ms): -8.875
Exact assignment patterns: 256
Two-sided permutation p-value: 0.0078125

The test enumerates 256 within-pair label patterns. Each pattern changes labels only inside a pair, which respects this assignment model.

Change and run again

In the Python editor, change the first two entries of b from 72, 119 to 90, 140. Select Run Python again. Compare Mean B-minus-A (ms), Exact assignment patterns and Two-sided permutation p-value. How do the two larger B times change the evidence without changing the pairing? Return to the Python editor

What this example supports. Exact here means all label assignments were enumerated, not that the design assumptions are known to hold. The timings are invented.

Try a fresh case

In a randomised paired trial, which label permutation respects assignment?

Choose an answer

Hints for this question
  1. Find where randomisation occurred.
  2. Keep the blocking structure while changing the assigned treatment labels.
Your notes