Dr. Dunbar, however, was concerned with relaxed, contagious social laughter, not the tyrant’s cackle or the “polite titter” of awkward conversation. He said a classic example would be the dinner at which everyone else speaks a different language and someone makes an apparently hilarious but incomprehensible comment. “Everybody falls about laughing, and you look a little puzzled for about three seconds, but really you just can’t help falling about laughing yourself.”

To test the relationship of laughter of this sort to pain resistance, Dr. Dunbar did a series of six experiments. In five, participants watched excerpts of comedy videos, neutral videos or videos meant to promote good feeling but not laughter.

Among the comedy videos were excerpts from “The Simpsons,” “Friends” and “South Park,” as well as from performances by standup comedians like Eddie Izzard. The neutral videos included “Barking Mad,” a documentary on pet training, and a golfing program. The positive but unfunny videos included excerpts from shows about nature, like the “Jungles” episode of “Planet Earth.”

In the lab experiments, the participants were tested before and after seeing different combinations of videos. They suffered the frozen wine sleeve or the blood pressure cuff in different experiments and were asked to say when the pain reached a point they could not stand. They wore recorders during the videos so that the time they spent laughing could be established. In the one real-world experiment, similar tests were conducted at performances of an improvisational comedy group, the Oxford Imps.

The results, when analyzed, showed that laughing increased pain resistance, whereas simple good feeling in a group setting did not. Pain resistance is used as an indicator of endorphin levels because their presence in the brain is difficult to test; the molecules would not appear in blood samples because they are among the brain chemicals that are prevented from entering circulating blood by the so-called blood brain barrier.

Dr. Dunbar thinks laughter may have been favored by evolution because it helped bring human groups together, the way other activities like dancing and singing do. Those activities also produce endorphins, he said, and physical activity is important in them as well. “Laughter is an early mechanism to bond social groups,” he said. “Primates use it.”

Indeed, apes are known to laugh, although in a different way than humans. They pant. “Panting is the sound of rough-and-tumble play,” Dr. Provine said. It becomes a “ritualization” of the sound of play. And in the course of the evolution of human beings, he suggests, “Pant, pant becomes ha, ha.”