Scientists have used a mathematical equation to accurately predict the happiness of more than 18,000 people around the world.

The formula for happiness, according to the equation, depends on whether things are better than expected, and not just on how well things are going.

People felt happiest when they performed better than expected on a risk-reward task.

For their initial study, researchers at University College London used a smaller sample size of 26 subjects to formulate the mathematical equation. The subjects completed a decision-making task in which their choices led to monetary gains or losses. Meanwhile, they were also repeatedly asked, “How happy are you right now?”

By measuring the subjects’ neural activity, the researchers built a computational model which explained the relationship between self-reported happiness and recent rewards and expectations.

According to the formula, momentary happiness depended not only on how well things are going, but also on whether things are going better than expected.

This model was then tested on 18,420 participants worldwide via a smartphone app, which was developed by the university (but instead of winning money, subjects would win points).

Interestingly, the researchers accurately predicted the happiness of the subjects using the same computation model.

Whether subjects won money or points, the researchers found that the amount they won wasn't a good predicator of happiness. Instead, happiness depended on the recent history of rewards and expectations.

"It's great that the data from the large and varied population using 'The Great Brain Experiment' smartphone app shows that the same happiness equation applies to thousands people worldwide playing our game, as with our much smaller laboratory-based experiments,” said lead author of the study, Dr Robb Rutledge,"which demonstrate the tremendous value of this approach for studying human well-being on a large scale."

Dr Rutledge said he was surprised that expectations played such an important role in determining happiness.

"We expected to see that recent rewards would affect moment-to-moment happiness but were surprised to find just how important expectations are in determining happiness,” he said.

“In real-world situations, the rewards associated with life decisions such as starting a new job or getting married are often not realised for a long time, and our results suggest expectations related to these decisions, good and bad, have a big effect on happiness."

Based on the results, he also said that lowering expectations could make you happier.

"It is often said that you will be happier if your expectations are lower. We find that there is some truth to this: lower expectations make it more likely that an outcome will exceed those expectations and have a positive impact on happiness.

“However, expectations also affect happiness even before we learn the outcome of a decision. If you have plans to meet a friend at your favourite restaurant, those positive expectations may increase your happiness as soon as you make the plan.

“The new equation captures these different effects of expectations and allows happiness to be predicted based on the combined effects of many past events.”

By mathematically quantifying happiness, the researchers believe it could help doctors better understand mood disorders and how individuals respond differently to circumstances, which will hopefully lead to more effective treatments.