We’ve all heard about how “living in the moment” is one of the keys to happiness. Well, some new research supports that idea, showing that people tend to be less happy when they let their minds wander.

Matthew Killingsworth and Daniel Gilbert of Harvard University are conducting an unusual study involving a special iPhone app called Track Your Happiness. The app enables them to contact people at random moments to find out all sorts of things, including what they are thinking about, what they are doing and how they are feeling. So far they have collected nearly a quarter-million pieces of data from about 5,000 people ranging in age from 18 to 88 from 83 countries.

In a report in this week’s issue of the journal Science, the researchers analyzed data from 2,250 volunteers in the United States to find out how happy they were, what they were doing and whether they were thinking about their current activity or something else, and whether that something else was pleasant, neutral or unpleasant. They could choose from 22 activities, such as walking, eating, shopping, watching television and having sex.

On average, the volunteers reported that their minds wandered 46.9 percent of the time, and no less than 30 percent of the time during every activity, except sex.

People reported being happiest when they were engaging in sex, exercise and conversation. They were the least happy when they were resting, working or using a computer at home.

The analysis showed that people tended to be less happy when their minds were wandering than when they were not, and this was true no matter what they were doing, even if it was something that they considered the least enjoyable, the researchers reported. People’s minds were more likely to wander to pleasant topics than unpleasant topics, but they were no happier when they were thinking about nice things than they were when they were thinking about whatever they were doing. In fact, they were “considerably unhappier” when they were thinking about topics they described as unpleasant or even “neutral,” the researchers found.

While it is possible that the reason a person’s mind wanders is because they are unhappy, the researchers analyzed the timing of the data and found that “mind wandering in our sample was generally the cause, and not merely the consequence, of unhappiness,” they wrote.

In addition, researchers found that “what people were thinking was a better predictor of their happiness than was what they were doing.” The type of activity explained only 4.6 percent of a person’s happiness, but mind-wandering explained 10.8 percent, they said.

“In conclusion, a human mind is a wandering mind, and a wandering mind is an unhappy mind,” they said.