We’ve all heard stories of inspiration striking out of the blue. It seems as though the moment your mind wanders, ideas and answers spring out of the void. Sometimes you can think about a problem logically for hours, without getting anywhere — but as soon as you “zone out,” a clever solution pops into your head.

A number of studies have shown that focused attention to a task can reduce your creativity, while a certain amount of mental wandering can actually boost your creative process. For example, a 2006 study by Ap Dijksterhuis and Teun Meurs with the University of Amsterdam found people who engaged in “unconscious thought” before solving a problem did better than people who’d been focused on something consciously.

I’ve often solved tricky programming problems by walking away from the computer and lying down for a while.  Or even simply going for a literal walk in the park.

Also, a recent study by researchers led by U.C. Santa Barbara’s Benjamin Baird found that people who were allowed to let their minds wander scored better on one measure of creativity — the “Unusual Task” test.

There are a few ways to make sure that your time spent “spacing out” is actually productive, rather than just a waste:

1) Do something unchallenging…

2) Be aware that you’re zoning out…

3) Practice meditation…