GenerateRandomSearch

Counterbalance Order Generator

Counterbalancing with a Latin square gives every condition every position exactly once, which most people assume is the whole job. It is not. A plain square can still put condition B after condition A every single time, so any effect A has on B is inseparable from B itself — and no amount of position balance will show you. A Williams design fixes that: every ordered pair of conditions occurs equally often as immediate neighbours. That is what this builds, and it says out loud when an odd number of conditions makes it need twice as many orders.

What this generator does

Balances what follows what, not only what goes where. The station rotation generator here builds a Latin square for a classroom carousel — everybody visits every station once — which is position balance. This adds the property that carousel does not need and an experiment does: first-order carryover balance, so a condition never systematically precedes another. The table is then re-read to confirm both properties from the finished orders rather than from the construction.

How to use this tool

  1. List your conditions, one per line.
  2. Press build — you get one order per participant group.
  3. Assign participants to orders in rotation: participant 1 takes order 1, and so on round.
  4. Copy the table into your protocol.

Understanding the controls

Conditions
One per line, two to twelve. Which label is which is shuffled each time you press build, so the design is not always in the order you typed.

Worked examples

4 conditions
Four orders. Each of the twelve ordered pairs appears next to each other exactly once.
6 conditions
Six orders and thirty ordered pairs, each occurring once — six times five neighbour slots, exactly filled.
5 conditions
Ten orders, with a note explaining that an odd count needs 2n and that the second half is each order reversed.
A naive cyclic square
Rejected by the same check: position is balanced but condition 1 is always followed by condition 2.

Common use cases

  • Ordering tasks or stimuli in a within-subjects experiment
  • Rotating which product a usability participant sees first
  • Ordering versions in a taste, scent or listening test
  • Sequencing training modules so no module always follows the same one
  • Any repeated-measures design where order could plausibly matter

How this generator works

The first order is built by interleaving from both ends — 0, 1, n−1, 2, n−2 and so on — which is the Williams construction. That specific interleaving makes the differences between adjacent entries cover every non-zero value exactly once, and cycling the row then makes every ordered neighbour pair occur equally often. For an even number of conditions that takes n orders and every ordered pair appears exactly once. For an odd number it genuinely cannot be done in n, so the square is paired with its own reverse to give 2n orders in which every pair appears exactly twice. The finished orders are then checked as a Latin square and counted pair by pair for carryover balance.

Randomness and fairness

The only randomness is which of your labels is assigned to which position in the construction — so two runs give different-looking tables with identical properties. The design itself is deterministic: Williams' construction is a formula, not a search, which is why the guarantee holds every time rather than usually.

For how randomness is produced across the whole site, see how Generate Random works.

Assumptions this tool makes

  • Every participant experiences every condition exactly once, in one sitting or one series.
  • Participants are assigned to orders in rotation rather than picking their own.

Limitations and good to know

  • It balances order; it does not remove order effects. A balanced design makes an order effect estimable rather than absent.
  • It balances first-order carryover only — what immediately follows what. Effects that persist across two or more conditions are not controlled.
  • It says nothing about sample size. You need participants in multiples of the number of orders for the balance to be realised in your data.
  • It does not allocate participants to orders; assign them in rotation, or use the allocation generator.
  • The design is not stored, so copy the table into your protocol; regenerating gives a different labelling of the same structure.

Common mistakes

Running a number of participants that is not a multiple of the number of orders
The balance is realised across a complete set of orders. Twelve participants across four orders works; ten does not, and leaves two orders over-represented.
Using a plain Latin square and assuming it is counterbalanced
It balances position only. If condition B always follows A, a carryover effect from A is confounded with B — which is precisely what this design prevents.
Letting participants choose their order
That undoes the design entirely. Assign in rotation as they arrive.

Practical tips

  • Print the table and tick off each order as it is used, so the rotation does not drift.
  • Prefer an even number of conditions where the design allows — you halve the number of orders you need to fill.
  • Record which order each participant received; it is the variable that makes the balance analysable afterwards.

Privacy and your data

Your condition names stay in your browser. Nothing is uploaded, nothing is stored between visits, and nothing is written into the page address. Analytics records that the tool ran and how many orders it produced, never a condition name.

Frequently asked questions

Why do five conditions need ten orders?
Because with an odd number of conditions the neighbour pairs cannot be distributed evenly across n orders. Pairing the square with its own reverse gives 2n orders in which every ordered pair appears exactly twice, which is the smallest design with the property.
How is this different from the station rotation generator?
That builds a Latin square for a classroom carousel, where the guarantee needed is that nobody repeats a station. This adds carryover balance, which a carousel does not need and an experiment does.
Does counterbalancing remove order effects?
No. It spreads them evenly across conditions so they can be measured rather than confounded. If practice effects are large, balancing them does not make them go away.
Can I use it for a between-subjects design?
There is nothing to counterbalance if each participant sees one condition — use the participant allocation generator instead.