And that result is what Dr. Choi and her colleagues found when they applied Mendelian randomization to exercise and depression. To reach that conclusion, they turned first to the UK Biobank, an enormous database of genetic and health information for almost 400,000 men and women. There they identified people who carried at least one of several gene variants believed to increase the likelihood someone will be active. Most of those people were active, and few of them had experienced depression.

People without the snippets, meanwhile, tended to move less, and they also showed greater risks for depression.

Delving deeper, the scientists found that, statistically, the ideal amount of exercise to prevent depression started at about 15 minutes a day of running or other strenuous exercise. Less-taxing activities like fast walking, housework and so on also afforded protection against depression, but it took about an hour a day to have an effect.

Finally, to be sure that physical activity was affecting the risk for depression, and not the other way around, the scientists repeated the Mendelian style of analysis on a separate large genetic database. This time they looked for gene variants related to depression and whether people who carried those variants and a propensity for depression tended to be physically inactive. It turned out, they did not.

So, the researchers concluded, physical activity in this analysis lowered the risk for depression, but depression did not affect whether people exercised.

Mendelian randomization remains a mathematical exercise, of course, and in the real world, people’s lives and behaviors are shaped by more than genetics. Many factors no doubt play a role in who develops depression. The gene variants related to being active could, for instance, also and separately play some kind of antidepressant role, Dr. Choi says, adding that the intertwined genetic and behavioral linkages between exercise and mental health will require many more studies to disentangle.

But already these results do provide “strong evidence” that being physically active, whatever your genetic makeup, can help protect against depression, Dr. Choi says.