Each virtual participant completes both conditions in a within-subjects design — one score at test position 1, one at position 2. Participant i's score at position p is generated as:
score = baseline_i
+ trueEffect · [condition == B]
+ orderEffect · [position == 2]
+ noise ~ N(0, σ²)
Fixed order — every participant does A first, then B. Now "condition == B" and "position == 2" are perfectly confounded: every B score also carries the full order effect. The naive estimator, mean(B) − mean(A), equals trueEffect + orderEffect, so it is biased by exactly the order-effect slider's value.
Counterbalanced — half the participants run A→B, the other half B→A. Condition and test position are now decorrelated: each condition appears equally often at position 1 and position 2, so the order effect cancels out of the group averages and mean(B) − mean(A) converges back to the true treatment effect as sample size grows.
The top chart shows every participant's paired bars (faded = position 1, solid = position 2, blue = condition A, orange = condition B) for whichever design is active. The bottom chart plays both designs forward from the same underlying random draws, participant by participant, so you can watch the fixed-order line drift toward the biased asymptote (trueEffect + orderEffect, dashed orange) while the counterbalanced line settles on the true effect (dashed green).
- Participants — sample size; larger N shrinks the naive estimate's sampling noise around its (biased or unbiased) expectation.
- True treatment effect — the real causal effect of condition B vs A, built into the simulation as ground truth for comparison.
- Order effect — practice (positive) or fatigue (negative) added to every score taken at the second position, regardless of which condition it happens to be.
- Trial noise σ — per-trial measurement noise; higher σ widens the spread of bar heights and the wobble in the convergence lines without changing their expected value.