“It’s like economy class on a plane,” said Dr. Samson. Monkeys, he believes, have to rest longer to get the benefits of REM sleep.

The fossil record suggests that 20 million years ago, the ancestors of humans and other apes changed their sleeping habits because they became too big for branches. Today, no primate that weighs over 60 pounds sleeps on a branch. Instead, chimpanzees, bonobos and their cousins build sleeping platforms each night from sticks and other materials.

Dr. Samson and his colleagues have found that apes take great care in choosing trees to sleep in and the materials to build their platforms. The reason, he suspects, is that apes aim to get the best night’s rest they can.

Dr. Samson and the primatologist Robert W. Shumaker found that orangutans that got to make platforms of foam and other comfortable materials scored better on cognition tests the following day than apes that slept on straw.

Early human ancestors probably continued to sleep in trees until about two million years ago, Dr. Samson said. By 1.8 million years ago, new hominins like Homo erectus had left the trees. “I think we can be safe in saying Homo erectus slept on the ground,” Dr. Samson said.

Early humans probably slept around fires in large groups, able to ward off predators. The result, said Dr. Samson and Dr. Nunn, was the chance to get an even better night’s rest. Humans were able to fall more soundly asleep and to experience deeper bouts of REM sleep.

Since it took less time to get the benefits of REM sleep, humans were able to get by with less sleep over all than other primates. They gained a few extra waking hours each day, which they might have used to make new tools or share stories.