Why do we dream? And why are our dreams so uncanny?

That has preoccupied researchers for centuries, and competing theories on the purpose and content of dreams abound.

Now, a Tufts University neuroscientist suggests science should look toward artificial intelligence for answers. Erik Hoel describes his idea, which he has dubbed the "overfitted brain hypothesis," in an article in the journal Patterns.

His hypothesis doesn't rely on machines to figure out why dreams happen. Instead, it borrows lessons from how artificial intelligence learns.

Researchers train AIs — machines that mimic human intelligence — by feeding them lots and lots of data. But like humans, artificial intelligence has its limits. When it doesn't have enough data or is too reliant on the data it has been given, it can choke when it encounters new data or situations.

Researchers call that "overfitting," and they solve for it by introducing some randomness into their data. That injection of chaos helps AIs perform better.

Perhaps brains do that for themselves, Hoel writes. To counteract the input of our daily lives, brains could dream up weird and random scenarios to help them function better.

"The hallucinogenic, category-breaking, and fabulist quality of dreams means they are extremely different from the 'training set' of the animal (i.e., their daily experiences)," he writes. "The very strangeness of dreams in their divergence from waking experience . . . gives them their biological function."

The hypothesis would need plenty of experimental validation, but Hoel sees it as dovetailing or overlapping with other possible explanations for dreaming, such as the idea that dreams could help human brains "unlearn" unwanted information.

So sleep well. That outlandish dream world you'll inhabit tonight might be helping your brain stay sharper during waking hours.