Section 11.8

Randomization

Definition

Randomization is the step of experimental design in which a chance mechanism, fixed before any outcome is seen, decides which experimental unit §11.3 (the thing, such as a device, that receives one condition) gets which of the compared conditions, or in which order the conditions run. Because chance makes the choice, the assignment cannot depend on any property of the units or circumstances, known or unknown. Every such property is then balanced between the conditions on average over all possible assignments, but not necessarily in the one assignment drawn.

The idea

Two software versions, A and B, are compared on one board. All runs of A happen in the morning and all runs of B in the afternoon. In the afternoon a nearby wireless network gets busy. Bluetooth devices, microwave ovens and many Wi-Fi networks share the 2.4 gigahertz radio band, so packets are lost and resent, and responses slow down. B looks slower, but the data cannot say whether B or the afternoon caused the slowdown: the schedule tied the time of day to the version. A factor such as the time of day, which affects the outcome but is not what the experiment studies, is called a nuisance factor.

Randomization cuts that tie. If a coin decides before each run whether A or B comes next, the busy afternoon falls on runs of A about as often as on runs of B. The coin knows nothing about the radio, the temperature or the load, so it cannot favor either version on any of them, including factors nobody thought of. Dealing cards from a well-shuffled deck is a fair picture: no player is systematically given the high cards. The picture also shows the limit: one deal can still give one player all the aces.

How it works

  1. Name the experimental unit and the conditions. The unit is whatever receives one condition: a board, a boot session or a single run.

  2. Before any outcome is seen, fix the assignment scheme: the set of allowed assignments and the probability of each. Three schemes are common. Independent draws: every unit gets its condition from its own coin flip, so the group sizes vary. Complete randomization: the number of units per condition is fixed, and every split with those numbers is equally likely. Randomization within blocks: the units are first grouped by a known nuisance factor, such as the board, and chance assigns the conditions or their order inside each group (see the blocking §11.9 entry).

  3. Draw one assignment with a pseudorandom number generator, an algorithm §14.1 that computes a fixed sequence of random-looking numbers from a starting value called the seed. Record the scheme, the seed and the assignment actually drawn.

  4. Carry out exactly that assignment, and record every deviation with its reason.

  5. Analyze under the same scheme: compare the units and the groups that chance actually formed.

Random assignment is one of three uses of chance in an experiment, each supporting a different claim. Random assignment supports the claim that the condition caused the difference seen inside the experiment. Random sampling, choosing which units of a larger population take part, supports the claim that the result holds for that population. Random input generation, drawing the workload from a chosen distribution, decides which inputs the result describes. None of the three achieves the other two.

A recorded seed makes the draws reproducible; the validity of the design comes from chance deciding the assignment independently of the outcomes. Trying several seeds and keeping the one whose assignment looks convenient replaces chance with a choice, unless that selection rule was declared in advance and the analysis takes it into account. Running the same seed again shows that the procedure is reproducible; it is not an independent replication of the experiment.

Worked example

Three boards each run version A once and version B once. On each board an independent fair coin decides the order: heads means A first, tails means B first. Each board has 2 possible orders, so there are 2×2×2=82 \times 2 \times 2 = 8 equally likely combinations. Exactly one combination puts A first on all three boards, so its probability is 1/8=0.1251/8 = 0.125, or 12.5%. Adding the combination that puts B first everywhere, the chance that all three boards use the same order is 2/8=0.252/8 = 0.25. In one experiment out of four, every run of one version comes second, and any effect of coming second, such as a warmed-up board, is completely mixed with the effect of that version.

Complete randomization of the orders removes that risk. Take four boards and require that exactly two run A first and two run B first. The first board that runs A first can be any of 4 and the second any of the remaining 3, and each pair is then counted twice, so there are (4×3)/2=6(4 \times 3)/2 = 6 ways to choose the two boards. Chance picks one of the 6, each with probability 1/61/6. Every allowed assignment has two boards of each order, so the order is balanced exactly, by construction. Other nuisance factors, such as which two boards happen to run A first, are still balanced only by chance.

Stated precisely

Let nn units receive either the treatment (the changed condition) or the baseline (the reference condition) by complete randomization with n1n_1 treated units, where 0<n1<n0 < n_1 < n. Each unit is then treated with probability n1/nn_1/n. Call the average over all allowed assignments, each weighted by its probability, the expected value. For any quantity xix_i of unit ii that is fixed before the assignment, such as a board’s temperature, the expected mean of xx over the treated units equals the mean of xx over all nn units, and so does the expected mean over the baseline units. The expected difference between the two group means of xx is therefore 0, for every such quantity, measured or not.

The same argument gives the main guarantee: the mean outcome of the treated units minus that of the baseline units has an expected value equal to the average treatment effect, the average over all nn units of each unit’s outcome under treatment minus its outcome under baseline. This assumes that the assignment followed the declared scheme, that each unit’s outcome depends only on its own condition, and that each condition is one well-defined version; the causal inference §11.11 entry states the result in symbols.

A randomization test uses the scheme itself as the source of probability. Its null hypothesis, the claim under test, is that the condition changes no unit’s outcome, so that every outcome would be the same under any assignment. The test recomputes the chosen statistic, such as the difference of the group means, for every allowed assignment. When the allowed assignments are equally likely, as under complete randomization, the fraction of them whose statistic is at least as extreme as the observed one is the p-value §11.23. With 6 units and 3 per condition there are (6×5×4)/(3×2×1)=20(6 \times 5 \times 4)/(3 \times 2 \times 1) = 20 allowed assignments, so no outcome can give a one-sided p-value (one that counts extreme results in one direction only) below 1/20=0.051/20 = 0.05. If whole sessions were assigned to conditions, shuffling single measurements between the conditions uses the wrong set of assignments and overstates the evidence.

Limits and common mistakes

Randomization balances in expectation, not in each experiment. A small experiment can be badly unbalanced, with a chance of 1 in 4 in the three-board example, so check the drawn assignment against the known nuisance factors.

Randomization does not reduce noise. A randomized nuisance factor stays in the data as extra variation and widens the uncertainty of the result. Blocking removes a known factor from the comparison; randomization only keeps it from favoring one condition systematically, that is, on average over the possible assignments. A common rule of thumb is to block what you can and randomize what you cannot.

Randomization does not replace control; remove the nuisance factors that can be removed. In a radio experiment, switch off the unused radios of the test computer (the Linux command rfkill does this), keep USB 3 ports and cables, which emit noise in the 2.4 gigahertz band, away from the antenna. Before a long run, measure the failure rate of a configuration known to work, so that a bad radio environment shows up before it spoils the run. With the versions interleaved at random, failures whose rate follows the time of day under both versions point to the environment; failures that follow one version point to that version.

Randomization does not repair what happens after the assignment: units lost for reasons linked to the outcome (see the missing data and attrition §11.29 entry), units that affect one another, such as two boards that share a radio channel, or a condition that is not one well-defined version.

Haphazard is not random. Using whichever board was free, or the order that seemed natural, can follow a nuisance factor without anyone noticing.

Questions answered

Which nuisance factors remain balanced only probabilistically?

Every nuisance factor that the design does not hold fixed or balance by construction remains balanced only probabilistically. A nuisance factor is anything that affects the outcome but is not what the experiment studies: temperature, background load on the test computer, radio interference, battery charge, slow drift over time, differences between devices, and every factor nobody recorded. Randomization, the assignment of conditions by a declared chance mechanism, balances such factors on average over the assignments the scheme allows, not in the one assignment drawn, which in a small experiment can be clearly unbalanced. Only the factors the design controls are balanced exactly: a factor held constant, a factor that defines blocks each containing every condition, and an order fixed by a constraint, such as exactly half of the boards running version A first. For the rest, inspect the drawn assignment, block on the large known factors, and state which factors remain balanced only by chance.

Related entries: Experimental unit (§11.3), Blocking (§11.9), Causal inference (§11.11), Missing data and attrition (§11.29), Hypothesis test (§11.22), Internal validity (§11.45).