The ability to behave randomly can be a great asset. Think of the mouse trying to outrun a cat - moving in an erratic, unpredictable way makes it harder to catch.
In humans, this sort of behaviour is thought to be linked to creativity and cognitive complexity. But understanding the mind's capacity to produce randomness is difficult.
Recently, a team from Europe pitted humans and computers against one another in a series of tasks designed to measure random choice-making.
Around age 25, the researchers determined, people are best able to produce a random result.
Traditionally, computational tools for studying random behaviour have been limited, according to Assistant Professor Hector Zenil, an author of the study, published in Plos Computational Biology, and a co-leader of the Algorithmic Dynamics Lab at the Karolinska Institute in Sweden.
His team compiled five tasks of randomness. These included mimicking a series of random coin flips or dice rolls, guessing which card would appear when selected from a randomly shuffled deck, or arranging a grid of black and white boxes to look random.
More than 3,400 people from four to 91 years old participated in the experiment. The researchers assessed how participants did by using software to generate algorithmic short cuts for people's responses.
The sequences that were hardest for the computer to account for were considered the most random.
Measuring how participants performed against several factors, including age, sex and educational background, the researchers found a strong trend only with age.
On average, performance improved from childhood to the mid-20s. It then stayed relatively high until the 60s, after which it began to decline.
For those older than 60, though, there was no need to fret. Not only was the difference between participants aged 25 and those aged 60 relatively small, but there are probably other trade-offs influencing creative capacity, Prof Zenil said.
For instance, "you may be less able to produce randomness but have much more experience to draw from", he said.