What is happiness and how can we get more of it? For many years scientists have been trying to define the joy and well-being of happiness, how people come to experience it and how to help them get a bit more of it in their lives.

What we do know from research is that happiness is infectious. We're all more likely to be happier if we have a happy friend nearby.

And we know that money does matter. We need enough of it to live well - that makes us happier than not having money. But after a point, more money doesn't make a lot of difference.

Research in the journal Psychological Science shows that money spent on doing, rather than by buying things, works. Apparently an experience, such as a holiday or going skydiving, brings more happiness than a good shopping spree.

There have been many attempts to judge the happiness levels of countries and some have even suggested that this is a better measure of a nation's progress than looking at an economy through the lens of GDP (Gross Domestic Product).

Australia generally does well in the rankings. The World Happiness Report 2015 puts Australia in 10th place out of 158 countries.

The world happiness rankings are based on a range of metrics including life expectancy, social support, freedom to make choices and generosity of the general population. There are many others trying to measure well-being including the UN's Human Development Index, the Happy Planet Index, the Legatum Prosperity Index and the Gallup/Healthways Well-Being Index.

Now researchers have, using data from a major study, determined that happiness depends on whether things are better or worse than expected.

Robb Rutledge and colleagues, of the Max Planck University College London Centre for Computational Psychiatry and Ageing Research, designed a study looking at the relationship between rewards and happiness.

"Based on the data, we developed a mathematical equation to predict how self-reported happiness depends on past events," says Rutledge, writing about it for the OECD. "We found that happiness depends not on how well things are going, but whether things are going better or worse than expected."

For those who like mathematics, here's the formula the researchers came up with for happiness:

happiness-formula

The formula explained in brief:

"Happiness depends on safe choices (certain rewards, CR), expectations associated with risky choices (expected value, EV), and whether the outcomes of risky choices were better or worse than expected. This final variable is called a reward prediction error (RPE), the difference between the experienced outcome and the expectation."

To get a detailed explanation go HERE.

This all means, according to Rutledge, that your happiness should increase in anticipation as soon as you make a plan to meet a friend.

"If you manage to get a last-minute reservation at a popular new restaurant, your happiness might increase even more," he says.

"If the meal is good, but not quite as good as expected, your happiness should actually decrease."

The study shows how important expectations are but this doesn't mean low expectations (and being pleasantly surprised when events exceed your expectations) are a key to happiness.

"We often don't know the outcome of major life decisions for a long time, whether taking a new job or getting married, but our results suggest that positive expectations about those decisions will increase happiness," he says.

The equation has been used to predict the happiness of more than 18,000 people round the world playing a game on a smartphone app called the Great Brain Experiment.

The free app asks: "What makes me happy?" Players then choose between safe and risky options to win as many points as they can.

This article was originally published by Business Insider.

More from Business Insider: