Why do teenagers stay up late? Why do older adults have trouble sleeping? The answers may lie in the dangers of the darkness from prehistoric times.

The next time you have insomnia, look on the bright side.

You might simply be modeling behavior designed to prevent your primitive ancestors from being eaten by a saber-toothed tiger.

Researchers recently studied the Hadza tribe of Tanzania — hunter-gatherers who live in camps of about 30 people and face threats from predatory animals and rival tribes.

During their observations, researchers said they found that at least one member of the group was awake at all times during the night.

They said this “sentinel” behavior could help explain why teenagers tend to stay awake late, while older people are more likely to wake up early in the morning.

“Flexibility and variability in sleep patterns may well be an adaptation from our ancestral past,” said David Samson, PhD, a sleep researcher at Duke University, who led the study while at the University of Toronto. “Groups that had this natural variation probably survived more than others did.”

Other experts point out that superior night vision might have been another advantage to having young people be more awake when it’s dark outside.

The theory of nightime vigilance is not new.

Psychologist Frederick Snyder noted the same sentinel behavior among groups of animals more than a half-century ago.

But Samson’s study, published in the Proceedings of the Royal Society B, was the first to look at asynchronous sleep among a group of people whose environment and lifestyle closely matches that of prehistoric humans.

“Forty to 72 percent of the variability we see in chronotyping” — each individual’s internal clock, which determines sleep behavior based on circadian rhythms — “is explained by genetics,” Samson told Healthline. “The rest is variable by environment, culture, social factors, and now technological factors.”

Most sleep research is conducted in a lab setting, noted Samson, “not in an evolutionarily relevant context.”

Technology has allowed modern humans to control some of the key factors involved in sleep regulation, such as light and temperature.

The Hadza, by contrast, “have 24-hour exposure to the environment where our ancestors adapted and evolved, and one that has one of the lowest levels of light pollution in the world,” said Samson.

Age, Samson found, was the single factor that drove chronotype variability among the study subjects.

And while the findings alone may not provide a solution to insomnia or perceived problems like early wakefulness among older adults, the knowledge that this behavior is not abnormal could help ease anxiety as part of cognitive behavioral therapy.

“Across the lifespan, kids’ biological night starts earlier and then drifts later as they reach their teens,” said Michael A. Grandner, PhD, director of the Sleep & Health Research Program at the University of Arizona College of Medicine and a member of the Sleep Research Society’s scientific review committee.

“As we get older, it drifts earlier, which is why older people tend to open their eyes at the first sign of light,” Grandner told Healthline. “They’re not insomniacs. They may think the night is not over, but it is.”

Humans are real outliers in terms of sleep among primates, Samson noted.

“We sleep the least and the deepest,” he said.

The vigilance pattern observed among the Hadza, along with the ability to regulate temperature with fire, may have helped early humans create the kind of high-quality sleep environment that allowed more wakeful time to be spent on creativity and innovation rather than hunting and gathering.

“That’s a prerequisite for higher thought and some of the other characertistics of our species that we consider unique,” Samson said.

“We tend to see sleep as unproductive time and that’s really a mistake,” said Grandner. “It’s a biological requirement of life.”

Even primitive organisms that live only a few days have sleep periods.

“Performing all physiological functions at all times at maximum efficiency does not enhance survival,” Grandner said.

Some of our sleep behaviors have roots deep into our evolutionary past.

The human body clock is set to the rotation of the Earth around the sun, with a sleep-wake cycle that resets somewhere between every 24 or 25 hours.

The light of the rising sun, for example, triggers wakefulness.

“Over millions of years, the one thing that has never changed is the day-night cycle, so it makes sense that certain processes were assigned to either the day or nighttime,” said Grandner.

Learning is more efficient when you are awake, for example, while memory consolidation is more efficient when you are asleep.

Samson said the notion that electric lighting is at the root of modern sleep problems is an oversimplification.

He noted that humans have been lighting their environment with controlled fire for more than a million years.

However, blue-green artificial light — the kind emitted by your phone and computer screen — is known to depress melatonin production.

“There’s very clear research showing that exposure to this light within an hour of bedtime will inhibit your sleep time,” said Samson.

Interestingly, studies also show that the absence of light at night is not as critical to good sleep as exposure to natural light during the daytime.

“If you’re indoors all day, it’s important to get outside and get 20 or 30 minutes of daylight,” Samson advises.

The specific wavelength of light required to trigger wakefulness (firelight has no effect, for example) points to the ancient origins of our sleep patterns, said Grandner.

“The color of light through seawater just so happens to be the color our circadian system uses,” he pointed out.

He said that hints at a system that was developed long before our evolutionary ancestors crawled out of the sea.