Despite the anxieties of these times, happiness has been on the rise around the world in recent years, a new survey finds.

The upbeat outlook is attributed to economic growth in previously poor countries, democratization of others, and rising social tolerance for women and minority groups.

"It's a surprising finding," said University of Michigan political scientist Ronald Inglehart, who headed up the survey. "It's widely believed that it's almost impossible to raise an entire country's happiness level."

Denmark is the happiest nation and Zimbabwe the the most glum, he found. (Zimbabwe's longtime ruler Robert Mugabe was sworn in as president for a sixth term Sunday after a widely discredited runoff in which he was the only candidate. Observers said the runoff was marred by violence and intimidation.)

The United States ranks 16th.

The results of the survey, going back an average of 17 years in 52 countries and involving 350,000 people, will be published in the July 2008 issue of the journal Perspectives on Psychological Science. Researchers have asked the same two questions over the years: "Taking all things together, would you say you are very happy, rather happy, not very happy, not at all happy?" And, "All things considered, how satisfied are you with your life as a whole these days?"

A Happiness Index created from the answers rose in 40 countries between 1981 and 2007, and it fell in the other 12.

Scientists had thought happiness is stable over time when looking at entire societies. "Most previous research suggests that people and nations are stuck on a 'hedonic treadmill,'" Inglehart said. "The belief has been that no matter what happens or what we do, basic happiness levels are stable and don't really change."

So Inglehart's team was surprised that happiness "rose substantially." They speculate reasons for the sunny outlooks include societal shifts in recent decades: Low-income countries such as India and China have experienced unprecedented rates of economic growth; dozens of medium-income countries have democratized; and there has been a sharp rise of gender equality and tolerance of ethnic minorities and gays and lesbians in developed societies.

Previous research has found that happiness is partly inherited and that money doesn't buy much of it.

Yet the new survey finds people of rich countries tend to be happier than those of poor countries. And controlling for economic factors, certain types of societies are much happier than others.

"The results clearly show that the happiest societies are those that allow people the freedom to choose how to live their lives," Inglehart said.

A survey released last week found one reason America doesn't top the list: Baby Boomers are generally miserable compared to other generations. Further, a public opinion poll released by the Pew Research Center in April found that 81 percent of Americans say they believe the country is on the "wrong track." The response is the most negative in the 25 years pollsters have asked the question.

The World Values Surveys, led by Inglehart, was funded by the National Science Foundation, the Swedish and Netherlands Foreign Ministries, and other institutions.

The Associated Press contributed to this report.