Randomization methods

The three methods Randomizer offers, each stated as a rule for the probability of the next assignment, with its balance and predictability and the published work it rests on. Use it to choose a method, to describe it in a protocol, or to check what the software does.

Contents

Notation

A study has k groups in the allocation ratio r1:r2:…:rk of positive integers. The target share of group i is

pi=riR,R=∑j=1krj

so 1:3:2 gives shares 1/6, 1/2 and 1/3. Participants are randomized one at a time, in the order they enroll. Write Tt∈{1,…,k} for the group of participant t. After n participants,

Ni(n)=∑t=1n1{Tt=i},Di(n)=Ni(n)−npi
Ni(n)
is the number of the first n participants in group i,
Di(n)
is how far group i is from its target, positive when over,
1{·}
is 1 when the condition inside holds and 0 otherwise.

Each method is defined by its allocation probabilities

φi(n)=P(Tn=i|ℱn−1)
ℱn−1
is everything known before participant n is randomized: the earlier assignments, the earlier participants' factor levels, and the new participant's own.

Each method is judged on two properties. Balance is how far Di(n) can stray from 0. Predictability is how well someone who knows ℱn−1 can guess Tn. A rule with φi(n)=pi whatever the history can't be predicted but can drift out of balance. A rule that steers every Di back to 0 stays balanced but becomes predictable. Every restricted method trades one for the other [3, 21].

Simple randomization

Each participant's group is drawn independently of everyone else's [1, 22].

Allocation rule

φi(n)=pifor every n and every history ℱn−1

Factor levels are recorded but play no part.

Balance

The assignments T1,T2,… are independent and identically distributed, so each group's size is binomial [16, 21]:

Ni(n)∼Binomial(n,pi),E[Di(n)]=0,Var(Di(n))=npi(1−pi)

The groups match the ratio only on average. The standard deviation of Di(n) grows like n, while the share Di(n)/n shrinks like 1/n: with 1:1 and n=100, each group's size has standard deviation 5. For two groups at 1:1, the chance that the larger one holds at least a share s of the participants is

P(max(N1,N2)≥sn)=2−n∑x:max(x,n−x)≥sn(nx)
x
runs over the possible sizes 0 to n of group 1,
s
is the share that counts as imbalanced, here 0.6.
Simple 1:1 randomization: chance of a 60:40 split or worse
Participants nChance
1075.4%
2050.3%
5020.3%
1005.7%
2000.6%
500< 0.1%

Imbalance is a real risk in small studies and negligible in large ones. Since Di is a random walk, the groups can also drift apart for long stretches, which matters if participants enrolled early differ from those enrolled late [16].

Predictability

Let the guess γ be any function of ℱn−1. Then

P(Tn=γ|ℱn−1)=pγ≤maxipi

with equality for always guessing the largest group. The history doesn't help: with 1:1, every strategy is right exactly half the time. In Blackwell and Hodges' model of selection bias there is nothing to exploit [4, 15].

Permuted block randomization

Participants are assigned in consecutive blocks. Each block holds every group in exactly the target ratio, in random order, so the groups return to the ratio at the end of every block [26, 17].

Allocation rule

A block of size b, a multiple of R, has

mi=bpi=briR

places for group i: 2 and 4 for 1:2 in blocks of 6. Its order is drawn uniformly from the

b!m1!m2!⋯mk!

distinct sequences with those counts: 6 for 1:1 in blocks of 4 (AABB, ABAB, ABBA, BAAB, BABA, BBAA), 20 in blocks of 6, 15 for 1:2 in blocks of 6, and 90 for 1:1:1 in blocks of 6. A uniformly random shuffle of the places, such as the Fisher–Yates shuffle, gives exactly this distribution [8, 6].

Equivalently, the block is drawn without replacement from an urn holding mi balls for each group i. For a participant who comes after τ others in the current block,

φi(n)=mi−uib−τ
b
is the size of the current block,
τ
is how many of its places are filled, 0≤τ<b,
ui
is how many of those τ went to group i, so mi−ui places are left for it.

Random block sizes

Each block's size is drawn independently from the allowed sizes:

P(b=sj)=wj∑l=1Jwl,j=1,…,J
sj
is an allowed block size, a multiple of R,
wj
is its weight, a positive integer,
J
is the number of allowed sizes.

The default is {2R,3R} with equal weights, so blocks of 4 or 6 for 1:1. Varying the size at random makes it much harder to tell where one block ends and the next begins [23].

Balance

Di(n)=0 at the end of every block. Within a block,

|Di(n)|≤bmaxpi(1−pi)
bmax
is the largest allowed block size.

Since the earlier blocks are complete, Di(n)=ui−τpi. The excess is largest when group i's places all come first: τ=ui=mi gives mi(1−pi). The shortfall is largest when they all come last: τ=b−mi and ui=0 give (b−mi)pi. Both equal bpi(1−pi). For two groups at 1:1 this means |N1−N2|≤bmax/2 at every point in the study. If enrollment stops partway through a block, the final groups can be off the ratio by up to this bound.

Predictability

Someone who knows the earlier assignments and the block size does best by guessing the group with the most places left [4, 17], the one that maximizes φi(n). Once one group's places are used up, the rest of the block is certain. For 1:1 blocks of a fixed, known size b,

C(b)=12+1b(2b−1(bb/2)−12)
K(b)=1b∑j=1b/2j·2(b−j−1b/2−1)(bb/2)
C(b)
is the expected share of assignments guessed right,
K(b)
is the expected share known for certain,
j
is the length of the run of one group that ends the block; the fraction is the chance that this run has length exactly j, and its j assignments are the certain ones.
1:1 blocks of a fixed, known size
Block size bPossible orders Guessed right C(b) Known for certain K(b)
2275%50%
4670.8%33.3%
62068.3%25%
87066.6%20%
1025265.3%16.7%

Simple randomization has C=1/2 and K=0. Random block sizes lower both, since a guesser no longer knows b or where a block ends. They don't remove predictability altogether: every restricted method trades some of it for balance [3].

Strata

In a stratified study, each of the S strata (every combination of factor levels, such as Boston · Female) runs its own, independent sequence of blocks, so the groups are balanced within each stratum. The study-wide imbalance is the sum of the strata's,

Di(n)=∑h=1SDi(h)(nh),|Di(n)|≤Sbmaxpi(1−pi)
S
is the number of strata (see Stratification factors),
nh
is the number of participants so far in stratum h,
Di(h)
is group i's departure from target within stratum h.

With many strata and few participants in each, most blocks are never finished and the balance blocking was meant to give is lost [9, 13]. Keep S small compared with n, or use minimization. Analyses should adjust for the stratification factors: leaving them out makes confidence intervals too wide and costs power [12].

Minimization

Minimization assigns each participant, with high probability, to the group that leaves their own factor levels most balanced across the whole study. Taves introduced it as a deterministic rule [25], and Pocock and Simon generalized it and added chance [19]. It balances each factor's margins, not every combination of levels, so it copes with many factors in small studies where stratified blocks would leave most strata nearly empty [24, 2].

Allocation rule

Arms. Let r~i=ri/gcd(r1,…,rk) be the reduced ratio. Group i is split into r~i arms of equal ratio, giving A=∑ir~i arms in all, and g(a) is the group of arm a. 1:1 and 2:2 give two arms; 2:1 gives three, A₁, A₂ and B. Unequal ratios explains why.

Counts. There are F factors, and factor f has levels 1,…,Lf. Before participant n,

xfℓa=∑t<n1{ℓtf=ℓ,αt=a},𝐱fℓ=(xfℓ1,…,xfℓA)
ℓtf
is participant t's level of factor f,
αt
is participant t's arm,
xfℓa
is how many earlier participants with level ℓ of factor f are in arm a.

Scores. Each arm is scored by the imbalance it would leave in participant n's own levels:

Ga=∑f=1Fd(𝐱fℓnf+𝐞a),a=1,…,A
𝐞a
is the unit vector with 1 in position a, so 𝐱fℓnf+𝐞a are the counts if the participant joins arm a,
d
is the imbalance measure, which maps A counts to a number that is 0 when they are all equal (see Imbalance measures).

Every factor weighs the same, and levels the participant doesn't have don't enter. With no factors, Ga=d(𝐍+𝐞a) on the arm totals 𝐍, which balances the group sizes.

Choice. Split the arms into the best and the rest,

B={a:Ga=mincGc},O={1,…,A}∖B

and pick arm a with probability

P(arm a)={π|B|if a∈B and O≠∅1−π|O|if a∈O1Aif O=∅, when every arm ties
π
is the preferred probability, the chance of picking from the best arms, from 1/2 to 1 and 0.8 by default,
|B|,|O|
are the numbers of arms in each set.

The participant joins the group of the chosen arm, so φi(n)=∑a:g(a)=iP(arm a), and the arm's count goes up by one in each of their levels. Unlike stratified blocks, there is one set of counts for the whole study.

Imbalance measures

Pocock and Simon left the measure of imbalance open. The range and the variance are the usual choices [19, 24]. For counts 𝐜=(c1,…,cA),

drange(𝐜)=maxaca−minaca
dvariance(𝐜)=A∑a=1Aca2−(∑a=1Aca)2=A2σ2(𝐜)
σ2(𝐜)
is the population variance of the counts, 1A∑a(ca−𝑐̄)2, and 𝑐̄ is their mean.

The factor A2 is the same for every arm and factor, so it changes no comparison, and it makes dvariance a whole number for whole-number counts. For counts (2, 1, 1), 3·6−42=2=9·29. The range looks only at the largest and smallest counts; the variance counts every arm, which matters with three or more. With two arms, dvariance=(c1−c2)2. The variance is the default.

Continuous factors

Binning a continuous factor like age throws information away: an 18-year-old and a 29-year-old in the same bin count alike, so the groups' mean ages can drift apart within every bin. By default, minimization balances a continuous factor on its values instead, through its first two moments. Bins remain an option.

Let v1,…,vn be the factor's values for participants 1 to n, the new participant included. Standardize them with their mean and standard deviation,

𝑣̄=1n∑t=1nvt,s2=1n∑t=1n(vt−𝑣̄)2,zt=vt−𝑣̄s

and apply the first three normalized Hermite polynomials,

ψ0(z)=1,ψ1(z)=z,ψ2(z)=z2−12

summed over each arm's earlier participants:

Hja=∑t<n:t in arm aψj(zt),𝐇j=(Hj1,…,HjA)

The factor then adds to the score Ga, in place of a level's d(𝐱fℓnf+𝐞a),

13∑j=02d(𝐇j+ψj(zn)𝐞a)
𝑣̄,s
are the mean and population standard deviation of all n values, recomputed for every new participant,
zn
is the new participant's standardized value,
H0a
is the number of earlier participants in arm a,
H1a
is 0 for every arm when every arm's mean is 𝑣̄,
H2a
is 0 for every arm when every arm's mean square deviation from 𝑣̄ is s2.

The three functions are orthonormal under the standard normal distribution: E[ψj(Z)ψl(Z)]=δjl for Z∼N(0,1). So for normally distributed values the three contributions are uncorrelated and on the same scale, and none outweighs the others. Dividing by 3 makes the factor weigh as much as a factor with levels. When s=0, before the values vary, only the j=0 term is scored.

Since 𝑣̄ and s change with every participant, the sums Hja are recomputed each time, from three running sums per arm:

H1a=Sa−na𝑣̄s,H2a=12(Qa−2𝑣̄Sa+na𝑣̄2s2−na)
na
is the number of earlier participants in arm a, which is H0a,
Sa
is the sum of their values,
Qa
is the sum of their squared values.

The analysis can then adjust for the value itself rather than its bin, so nothing is lost to the cut points.

The preferred probability

  • π=1 always picks a best arm, so chance settles only ties: Taves's original method [25]. Anyone who knows the counts can then predict most assignments, and reviews recommend keeping a random element [24].
  • π=1/2 with A=2 gives φi(n)=1/2 whatever the scores: simple randomization.
  • With A=2 and no factors, the rule is Efron's biased coin [7]: the smaller group gets probability π, and a tie gives each group 1/2. Efron suggested π=2/3.

Unequal ratios

With unequal allocation, minimizing over the groups directly pulls them toward equal sizes. Ad hoc fixes can make each group's probability drift away from the target from one assignment to the next, which distorts the re-randomization distribution used to analyse the trial [20, 14]. Kuznetsova and Tymofyeyev call a procedure allocation ratio preserving when

P(Tn=i)=pifor every n and i

where the probability is unconditional, taken over every possible history.

Minimization over arms has this property. Relabelling the arms by any permutation relabels the scores, the sets B and O and the probabilities in the same way, and all counts start at zero. So the distribution of the sequence of arms is unchanged by relabelling, each arm has unconditional probability 1/A at every step, and

P(Tn=i)=∑a:g(a)=i1A=r~iA=riR=pi

Balancing the arms then holds each factor level's groups near the ratio. Han, Enas and McEntegart, and Kuznetsova and Tymofyeyev, describe other approaches [10, 14].

Worked example

Two groups at 1:1, so A=2; factors Site (Boston, Chicago) and Sex (Female, Male); drange; π=0.8. The next participant is a woman in Boston, and so far 𝐱Boston=(5,3) and 𝐱Female=(4,3).

Scores for a woman in Boston
Arm a𝐱Boston+𝐞a𝐱Female+𝐞aGa
A(6, 3), range 3(5, 3), range 25
B(5, 4), range 1(4, 4), range 01

So B={B}, and the participant goes to B with probability 0.8 and to A with 0.2. Chicago and Male don't enter, since only the participant's own levels are scored. With dvariance the scores are 9+4=13 and 1+0=1, and the choice is the same.

With 2:1 instead, the arms are A₁, A₂ and B. Before anyone enrolls all three score the same, so O=∅, each arm has probability 1/3 and group A has 2/3.

As with stratified blocks, analyses should adjust for the minimization factors [12].

Stratification factors

Each participant has one level of each of F factors. With Lf levels in factor f, the number of strata is

S=∏f=1FLf

so three factors of three levels make 27. A study with sites can also be stratified by site, which adds site as a factor.

Continuous factors in bins

A whole-number factor like age, with values from vmin to vmax, can be split into L bins of near-equal width. Divide the number of values by the number of bins,

V=vmax−vmin+1=qL+ε,0≤ε<L

Bin j=0,…,L−1 then holds the values from aj to aj+1−1, where

aj=vmin+jq+min(j,ε)
V
is the number of possible values,
q
is the width every bin has at least,
ε
is the number of bins, the first ones, that hold one value more.

Ages 18 to 64 in four bins give V=47=11·4+3, so 18–29, 30–41, 42–53 and 54–64. Minimization can balance on the values instead; see Continuous factors.

How each method uses them

  • Simple randomization records them but ignores them.
  • Permuted blocks run a separate block sequence in each stratum.
  • Minimization balances each factor's levels across the whole study, and continuous factors by value or by bin.

Randomizing sites

A study can randomize whole sites instead of participants (cluster randomization). Every formula above then applies with sites in place of participants: n counts sites, the factors describe sites (region or size, say), and each site is randomized once, when it's added. Every participant at a site takes the site's group.

Participants at one site tend to be more alike than participants at different sites, so a cluster trial needs more participants than an individually randomized one, by the design effect

DE=1+(m−1)ρ
m
is the number of participants per site, taken as equal,
ρ
is the intracluster correlation.

The analysis must allow for the clustering [5]. Sites are usually few, and the binomial table shows how uneven simple randomization then is: 10 sites split 6:4 or worse three times in four. Permuted blocks or minimization are usually better.

Choosing a method

The three methods compared
MethodGroup sizesFactorsPredictability
SimpleSD(Di)=npi(1−pi), uneven in small studies Balanced on averageNone
Permuted blocks|N1−N2|≤bmax/2 for 1:1, in each stratum Balanced within strata, if strata are fewSome, reduced by random block sizes
MinimizationClose to the ratioEach factor balanced across the study, even with many Some, set by π
  • Simple randomization suits large studies, where chance imbalance is small and complete unpredictability is worth most.
  • Permuted blocks are the usual choice for small and medium studies, stratified by one or two important factors such as site.
  • Minimization suits small studies that must balance several factors at once.

Implementation

What a protocol or an audit may need beyond the definitions above.

  • Random numbers. Every draw is Node.js's crypto.randomInt(m), uniform on {0,…,m−1} from the operating system's cryptographically secure generator, without modulo bias [18]. Ratios, block-size weights and π (set in whole percent) are whole numbers, so every probability above is realized exactly: a draw on {0,…,R−1} picks group i for exactly ri of its values. Shuffles use Durstenfeld's version of Fisher–Yates.
  • Concealment. Each participant is assigned when they enroll, on the server; no list is generated in advance. The rest of the current block and the minimization counts are kept where no user or browser can read them, so the people enrolling can't know the next group before a participant is committed [23]. Enrollments made at the same moment are handled one after another, each seeing the state the previous one left.
  • Ties. With continuous factors the scores aren't whole numbers, so arms within a relative 10−12 of the lowest score count as tied.
  • Changes mid-study. A block that no longer fits changed ratios or block sizes is abandoned and a new one started. In minimization, each group's counts are spread over its new arms.
  • Limits. 2 to 10 groups, with ratio shares from 1 to 99; up to 10 block sizes from 2 to 1,000, with weights from 1 to 99; up to 10 factors of 2 to 10 levels; and π from 50% to 100%. Once the target sample size is randomized across all strata, enrollment is refused.
  • Who sees the settings. Every member of a project can see the allowed block sizes and weights. In an unblinded study, use more than one size, and don't share them with the people enrolling.
  • Reporting. CONSORT 2025 asks trial reports to state how the allocation sequence was generated, the type of randomization and any restriction, such as blocking or stratification, and how allocation was concealed [11].

References

  1. Altman DG, Bland JM. How to randomise. BMJ. 1999;319(7211):703–4. https://doi.org/10.1136/bmj.319.7211.703
  2. Altman DG, Bland JM. Treatment allocation by minimisation. BMJ. 2005;330(7495):843. https://doi.org/10.1136/bmj.330.7495.843
  3. Berger VW, Ivanova A, Deloria Knoll M. Minimizing predictability while retaining balance through the use of less restrictive randomization procedures. Stat Med. 2003;22(19):3017–28. https://doi.org/10.1002/sim.1538
  4. Blackwell D, Hodges JL. Design for the control of selection bias. Ann Math Stat. 1957;28(2):449–60. https://doi.org/10.1214/aoms/1177706973
  5. Campbell MK, Piaggio G, Elbourne DR, Altman DG. Consort 2010 statement: extension to cluster randomised trials. BMJ. 2012;345:e5661. https://doi.org/10.1136/bmj.e5661
  6. Durstenfeld R. Algorithm 235: Random permutation. Commun ACM. 1964;7(7):420. https://doi.org/10.1145/364520.364540
  7. Efron B. Forcing a sequential experiment to be balanced. Biometrika. 1971;58(3):403–17. https://doi.org/10.1093/biomet/58.3.403
  8. Fisher RA, Yates F. Statistical tables for biological, agricultural and medical research. London: Oliver and Boyd; 1938.
  9. Hallstrom A, Davis K. Imbalance in treatment assignments in stratified blocked randomization. Control Clin Trials. 1988;9(4):375–82. https://doi.org/10.1016/0197-2456(88)90050-5
  10. Han B, Enas NH, McEntegart D. Randomization by minimization for unbalanced treatment allocation. Stat Med. 2009;28(27):3329–46. https://doi.org/10.1002/sim.3710
  11. Hopewell S, Chan AW, Collins GS, et al. CONSORT 2025 statement: updated guideline for reporting randomised trials. BMJ. 2025;389:e081123. https://doi.org/10.1136/bmj-2024-081123
  12. Kahan BC, Morris TP. Improper analysis of trials randomised using stratified blocks or minimisation. Stat Med. 2012;31(4):328–40. https://doi.org/10.1002/sim.4431
  13. Kernan WN, Viscoli CM, Makuch RW, Brass LM, Horwitz RI. Stratified randomization for clinical trials. J Clin Epidemiol. 1999;52(1):19–26. https://doi.org/10.1016/S0895-4356(98)00138-3
  14. Kuznetsova OM, Tymofyeyev Y. Preserving the allocation ratio at every allocation with biased coin randomization and minimization in studies with unequal allocation. Stat Med. 2012;31(8):701–23. https://doi.org/10.1002/sim.4447
  15. Lachin JM. Statistical properties of randomization in clinical trials. Control Clin Trials. 1988;9(4):289–311. https://doi.org/10.1016/0197-2456(88)90045-1
  16. Lachin JM. Properties of simple randomization in clinical trials. Control Clin Trials. 1988;9(4):312–26. https://doi.org/10.1016/0197-2456(88)90046-3
  17. Matts JP, Lachin JM. Properties of permuted-block randomization in clinical trials. Control Clin Trials. 1988;9(4):327–44. https://doi.org/10.1016/0197-2456(88)90047-5
  18. Node.js. Crypto: crypto.randomInt([min, ]max[, callback]). Node.js documentation. https://nodejs.org/api/crypto.html#cryptorandomintmin-max-callback
  19. Pocock SJ, Simon R. Sequential treatment assignment with balancing for prognostic factors in the controlled clinical trial. Biometrics. 1975;31(1):103–15. https://doi.org/10.2307/2529712
  20. Proschan M, Brittain E, Kammerman L. Minimize the use of minimization with unequal allocation. Biometrics. 2011;67(3):1135–41. https://doi.org/10.1111/j.1541-0420.2010.01545.x
  21. Rosenberger WF, Lachin JM. Randomization in clinical trials: theory and practice. 2nd ed. Hoboken (NJ): Wiley; 2016. https://doi.org/10.1002/9781118742112
  22. Schulz KF, Grimes DA. Generation of allocation sequences in randomised trials: chance, not choice. Lancet. 2002;359(9305):515–9. https://doi.org/10.1016/S0140-6736(02)07683-3
  23. Schulz KF, Grimes DA. Allocation concealment in randomised trials: defending against deciphering. Lancet. 2002;359(9306):614–8. https://doi.org/10.1016/S0140-6736(02)07750-4
  24. Scott NW, McPherson GC, Ramsay CR, Campbell MK. The method of minimization for allocation to clinical trials: a review. Control Clin Trials. 2002;23(6):662–74. https://doi.org/10.1016/S0197-2456(02)00242-8
  25. Taves DR. Minimization: a new method of assigning patients to treatment and control groups. Clin Pharmacol Ther. 1974;15(5):443–53. https://doi.org/10.1002/cpt1974155443
  26. Zelen M. The randomization and stratification of patients to clinical trials. J Chronic Dis. 1974;27(7–8):365–75. https://doi.org/10.1016/0021-9681(74)90015-0