TactivergeLite

Lite / Independent Engineering Research / Week 32

Randomisation and confounding

You test gripper A all morning and gripper B all afternoon. B looks worse. Is it the gripper, or the tired battery?

About 45 min · 3 goals · Checked by automated tests · Full interactive version

Why should I care?

Confounders are the most common reason a careful-looking experiment gives the wrong answer. Randomisation is the cheapest protection ever invented: it costs nothing but a seed.

Predict

True effect 0, battery drains steadily, all A trials first then all B. On average, what will B − A show?

  1. About 0
  2. A negative 'effect' caused by the battery
  3. A positive effect
  4. It depends only on noise
Guess first, then reveal

B always runs on a weaker battery, so the drift appears as a false negative effect. Repeating this design gives the same wrong answer every time.

Discover

Set the true effect to 0 and drift to 10. Compare the bias over 300 repeats for each trial order. Then set drift to 0: does the order still matter? Finally set a true effect of 2 with drift 10: which schedule recovers it?

What the interactive shows (text version)

The confounding simulator plots 24 trial scores in order; circles are condition A and squares condition B. A battery drift lowers later trials. Choosing the order (blocked, alternating, ABBA, randomised) changes the estimated effect; the readout gives the average bias over 300 repeated sessions.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: Note how random assignment and blinding are introduced, and which confounders each protects against.

Control groups, randomisation and blinding: the ideas that make a comparison fair, explained with everyday examples.

“Controlled Experiments: Crash Course Statistics #9” by CrashCourse (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

Understand

Confounders

A confounder affects the outcome and changes along with the condition. Time of day, battery level, simulator warm-up, operator fatigue and the order of trials are classic ones. If a confounder is perfectly aligned with the condition, no statistics can separate them.

Breaking the link

Randomising the order makes the confounder independent of the condition on average. Counterbalancing (ABBA) cancels linear drift by design. Blocking groups trials by a known nuisance (e.g. per battery) and compares within blocks. All are better than 'all A then all B'.

Bias versus noise

Randomisation turns bias into noise: the confounder still adds variation, but it no longer pushes the estimate one way. More runs then shrink the noise. More runs of a confounded design only make you more confident in the wrong answer.

Explain it another way

Intuitive

If you always test the new shoes on downhill runs and the old ones uphill, the new shoes will look fast whatever they are.

Technical

Random assignment ensures that, in expectation, every pre-existing or time-varying factor is balanced between conditions, so E[estimate] = true effect.

Mathematical

With linear drift −D·t over n trials, blocked ordering gives bias ≈ −D/2 (the B block sits half a session later); randomised ordering gives bias with mean 0.

Applied

Simulators have confounders too: caches warming, adaptive step sizes, thermal state of a modelled motor. Seeded random ordering of conditions applies there as well.

Worked example 1

Drift lowers scores by 10 points over a 24-trial session. Blocked order, no true effect. Expected estimate?

A trials sit at positions 0–11 (average drop ≈ 2.4), B at 12–23 (≈ 7.6). Estimate ≈ −5.2: a false effect about half the total drift.

Common mix-ups

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 1. Which is a confounder in 'all baseline runs on Monday, all new-method runs on Tuesday'?
Practice 2. Why does ABBA ordering cancel linear drift?

points

Practice 4. A confounded design is repeated with 10× more runs. What happens?
Practice 5. You randomise trial order in code. What must you record?

Apply it

List three possible confounders in your capstone (including order and simulator state). For each, say whether you will randomise, counterbalance, block or hold it fixed, and record the seed you will use.

Reflect

Which confounder in your project would you never have noticed without being asked?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Reproducible by design: seeds, versions, dataPilots, controls and blinding →