We think they like randomness in design, but we don’t exactly. People like things that are sorta random, but not too random. When you literally scatter things randomly, they looked too clumped [1].

There are many ways around this problem, variations on randomness that people find more aesthetically pleasing. One of these ways is **random Latin squares**.

A Latin square of size *n* is an *n* × *n* grid filled with *n *different things—numbers, letters, colors, etc.— such that each kind of thing appears exactly once in each row and in each column. For example, 26 × 26 grid filled with the letters of the English alphabet is a Latin square if every row and every column contains the entire alphabet; no letters repeated and no letters missing.

A random Latin square is an arrangement that is random but subject to the constraint that it be a Latin square. Random Latin squares look nice because they’re somewhat random but they avoid certain kinds of repetition.

Suppose you have five different colors of tile and you need to lay down the tiles in a 10 × 20 grid. You want to lay down the tiles “randomly” but you don’t want too many of any one color to appear in a small area.

One way to do this would be to divide the 10 × 20 space into a grid of grids. Each subgrid is a 5 × 5 Latin square. Here’s an example.

The image above is a 2 × 4 grid of 5 × 5 grids, and each of the 5 × 5 grids is a Latin square chosen at random.

Here’s another example with five different colors and different random Latin squares.

If you look carefully, you’ll spot a few places where tiles of the same color touch on an edge. This cannot happen within a Latin square, but it can happen where two different Latin squares are next to each other. So the randomization scheme described here allows for a few tiles of the same color to touch but not many.

I expect randomized Latin squares are used this way fairly often. You’d never know, and that’s kinda the point. Someone would have to stare at a pattern like this a long time before they realized that horizontal or vertical segments of five do not repeat a color.

## Related posts

- Something like a random sequence but …
- Quasi-random sequences in art
- How many Latin squares are there?

[1] One way to detect fraud is to look for fake randomness. When people try to make something look random, they usually fail and leave statistically detectable fingerprints.

One drawback of this construction is that the “seams” are potentially visible. In the second picture, there are 7 pairs of identical tiles touching vertically and all are on the same line, which looks a bit weird.

A variation that avoids this issue might be to choose squares that overlap in one row or column, filling each one with a random Latin square subject to the constraint that the first row and column match what has already been placed.

One additional clarification may be in order…

The second set of Latin Squares begins by showing only 4 of the 5 squares in the horizontal direction.

I must admit that I did not notice this at first. It was only later as I helped my wife and sister to “engineer” the building of a gingerbread house which was putting repeated numbers of colored, sugar-shelled candies. I thought a Latin Square would be the perfect way to make this look random and pleasing to the eye (such thinking usually leads to my wife and sister not interested in my help.)