Random permuted block simulation

Investigate how block sizes and strata affect imbalance

Perform simulations to help you decide on the best block sizes to use in your trial. If you are using random permuted blocks, you need to decide on the block size (or sizes) to use. If the block size is small, and the trial is unblinded, it may be possible for investigators to guess the next treatment allocation. But if the block size is large, or you have many strata, the trial may end with many incomplete blocks. This increases the chance there will be imbalance in the number allocated to each treatment.

For 2:1 ratio enter same treatment group twice, e.g. A, A, B

e.g. 3 age-groups and 5 sites is 3 x 5 = 15 strata

Number of randomisations you intend to carry out in your trial

Number of trials to simulate - worst case scenario is particularly sensitive to this

How does this work?

When you run the simulations, a stratified randomisation list is generated using the treatment groups, block sizes, number of strata and sample size you have specified. To keep things simple, it is assumed that each stratum will receive approximately the same number of randomisations. Then the number randomised to each treatment group using this list is calculated, and the imbalance is recorded. This process is repeated thousands of times (as specified by the number of replications you chose) and the results aggregated.

Source code

The JavaScript source code used for these simulations is open source and is published here.

You can also run our tests for the source code to confirm that the simulation code works correctly in your browser.


Kernan WN, Viscoli CM, Makuch RW, Brass LM, Horwitz RI. Stratified randomization for clinical trials. J Clin Epidemiol; 1999.


The results of the simulations will be shown below. The imbalance is calculated at the end of each trial, assuming it met its target sample size and that randomisations were approximately evenly spread across the strata. Imbalance is the sum of the differences in the number randomised to each group overall compared to the optimum number if the trial was perfectly balanced.