If your head is overheated, there's a good chance you'll yawn, according to a new study that found the primary purpose of yawning is to control brain temperature.

The finding solves several mysteries about yawning, such as why it's most commonly done just before and after sleeping, why certain diseases lead to excessive yawning, and why breathing through the nose and cooling off the forehead often stop yawning.
The key yawn instigator appears to be brain temperature.
"Brains are like computers," says Andrew Gallup, a researcher in the Department of Biology at Binghamton University who led the study, which has been accepted for publication in the journal Animal Behavior.
"They operate most efficiently when cool, and physical adaptations have evolved to allow maximum cooling of the brain."
"In addition, yawning when it is extremely cold may be maladaptive, as this may send unusually cold air to the brain, which may produce a thermal shock."