Toolvito

Works on this device

Random Assignment Generator

Type or paste a list of people or items and assign each one to a group or a treatment at random. The result comes with a seed: a number that gives the same assignment again, so that you or someone else can check it later. The list stays on your device.

Enter the list and the groups

Every person or item goes to one group or treatment at random. The groups get the same number of people, or differ by one.

List and settings

One on each line, or all on one line with commas between them. Up to 5,000. Codes such as P01 are safer than real names.

Type the names with commas between them. Or type only a number, such as 4, for Group 1 to Group 4.

Leave this empty for a new random assignment. To get an earlier assignment again, type its seed (a whole number of up to 15 digits) and use the same list and settings.

More options

One rule on each line, such as "together: P03, P04" or "apart: P01, P02". Use the names as they stand in the list.

The assignment is made in this browser. The list is not sent to a server.

The assignment will show here

Choose Assign to draw it.

How to use the generator

  1. Choose how to assign: equal groups, groups of stated sizes, or blocks for a study.
  2. Type or paste the list, one person or item on each line. Codes such as P01 are safer than real names. You can also assign the numbers 1, 2, 3 … when the names are not known yet.
  3. Type the names of the groups or treatments, for example Treatment, Control. A plain number such as 4 gives Group 1 to Group 4.
  4. Leave Seed empty and choose Assign. Choose it again for a new assignment.
  5. Copy or download the table, the CSV text or the list by group. Keep the seed with your notes.

How the assignment is made

First the sizes of the groups are fixed. For equal groups, when the people do not split evenly, the groups differ by one person, and which groups get one more is drawn at random too.

Then the list is mixed with the Fisher-Yates shuffle. It goes through the list from the end, and swaps each place with a place chosen at random from the ones not yet fixed. Every order of the list has the same chance. The first people of the mixed list go to the first group, the next ones to the second group, and so on.

The random choices come from the seed. The seed starts a number generator named xoshiro128** (it is started through a step named SplitMix64). For one seed the generator always gives the same row of random bytes. A whole number is taken from these bytes without favouring any value: bytes that fall outside the needed range are thrown away.

When you leave the seed empty, your browser draws a fresh one with its secure random generator. The seed is shown in the result.

The seed: make the same assignment again

Type the seed of an earlier result into the Seed field, with the same list in the same order and the same settings. You get the same assignment. This lets another person check that the list was not changed after the draw.

For example, the starting list P01 to P12 in two equal groups with the seed 12345 always gives Treatment: P03, P06, P07, P08, P10, P12 and Control: P01, P02, P04, P05, P09, P11.

Anyone who knows the seed and the list can work out the assignment. If you choose the seed yourself, you could try several seeds and keep the one you like. For a fair draw, leave the seed empty, or agree on the seed before the list is known.

Blocks for a study

In a study, people often join one after the other. Blocks keep the treatments in balance all the way. You say what one block holds, for example Treatment 2 times and Control 2 times, which makes blocks of 4. For each block the tool mixes these 4 places. The people keep the order of your list: the first 4 get the first block, the next 4 the second block.

After every full block each treatment has had its share. If the last block is not full, the totals can differ a little.

Blocks have a known weak point: a person who knows the block size and sees the first assignments of a block can sometimes work out the last ones.

Keep people together or apart

Under More options you can add rules for equal groups and stated sizes, one on each line: together: P03, P04 or apart: P01, P02. The tool then makes the whole draw again and again until every rule holds, at most 2,000 times. This way each assignment that follows the rules has the same chance.

A rule that can never hold is refused with the reason, for example 3 people who must all be apart when there are only 2 groups. If the rules are not met in 2,000 draws, the tool stops and says so.

Worked example

12 people in 2 equal groups: each group gets 6. There are 924 different ways to do this, and each has the same chance.

13 people in 3 groups: 13 ÷ 3 is 4 with 1 left over, so two groups get 4 people and one group gets 5. Which group gets 5 is drawn at random.

10 people in blocks of 3 treatments (A, B and C once each): there are 4 blocks. The first 3 blocks are full, and the last block has 1 of its 3 places.

What this tool does not do

  • It does not hide the assignment from the person who runs it. In a clinical trial the allocation must be concealed, and this page cannot do that.
  • It keeps no record and nobody signs the result. Save the seed, the list and the settings yourself.
  • It does not balance the groups by age, sex, skill or any other trait, and it does not make strata. Only the group sizes, the blocks and your rules are kept.
  • It is not professional advice for the design of a study. A clinical trial needs a written plan and a statistician.
  • A list can hold up to 5,000 entries of at most 100 characters, in up to 100 groups. A block can have up to 200 places.
  • A fresh seed is one of 100,000,000,000,000 numbers. For a long list there are more possible assignments than seeds, so not every assignment can come up.
  • The page does not send the list to a server. A seed is not a secret: do not use it to make passwords or prize draws.

Related tools