When he was younger, neuroscientist Scott Weems once burst out laughing at his grandfather's funeral. Not everyone present saw the humor in the solemnities.

Funny thing is, Weems, author of Ha!: The Science of When We Laugh and Why, kept right on laughing at seemingly the most inappropriate times. So much so that he started to get a little self-conscious about it. Ultimately, all the angst spurred Weems to delve deep into the nature of humor in a big way.

"I wanted to know what was wrong with me and why I laughed at so many things that other people didn't necessarily think were funny," Weems says. What Weems soon discovered is that what appeared to family and friends gathered at his beloved grandfather's send-off as some very inappropriate laughter was actually totally understandable considering that humor is the product of unresolved conflict in the brain.

"I don't think that kind of thing is uncommon," Weems says. "You're sad, of course. But you've really got mixed emotions about it. You also want to feel happy for the person who, hopefully, had such a great life. Laughing (even at your grandfather's funeral) is a very human reaction."

Sometimes there's nothing else to do but laugh. "If that’s not the case for someone, they’re probably just not being very observant," Weems says. "No matter who you are, there’s going to be a lot that just does not make sense as a living creature. So there has to be a way to react to that. I like to think of humor as a very adaptive thing that we’ve developed, because without it, there wouldn’t be many alternative ways for us to respond."

Already possessed of a keen sense of humor, Weems now believes that a greater understanding about the science of jocularity has not only enabled him to find even more things to laugh at—but also to be funnier as well.

"This was something I was really interested in when I was writing the book, because I personally have no interest in being a comedian, but I would like to improve my own humor," Weems says. "And I think learning about humor definitely helps. But it’s like any other skill, it requires a combination of knowledge and practice. And so, I myself have not pursued the practice aspect of it, but I do see myself noticing humor a lot more. I see more instances that are possibilities for humor."

And with all deference to the late, great Philip K. Dick, the best way to out an android is probably not testing its ability to feel empathy but rather to see if you can make one of them giggle and guffaw.Weems_cover

"A lot of computers can trick people into thinking they are conscious," Weems points out. "But the best way to trip up a computer is to give it a joke. And that’s the best way to tell if you’re dealing with a conscious entity, as opposed to a computer. It’s terribly hard to get a computer to recognize jokes. Especially certain jokes, because many are just beyond a machine's comprehension."

Humor, no matter where or when it pops up, can also be good for you.

"Laughter improves our cardiovascular health because in a way, laughter is an aerobic exercise," Weems says. "But also, look at the way laughter improves our immune system responses, as well as reducing our allergic reactions to things. It seems that humor is like exercise for the mind. And just like exercise for the body, it’s good for the mind to be surprised and shocked. In a way, that's what humor does. It just has lots of wide-ranging positive effects on our health."

As a disciple of drollery and a supporter of schtick, Weems is one scientist who particularly enjoys locking up the lab and hitting the comedy clubs for some raucous standup. But for him, the best humor isn't always staged.

"I enjoy natural settings where people are humorous," Weems says. "I go to comedy shows all the time. But for me, the richest humor is just what emerges in daily life. You see humor in surprising places. Like seeing old friends for holidays. You might ask yourself why that is, and then you realize that there are some very complex emotions going on. And that can help you appreciate the relationships you have with the people you’re laughing with, a whole lot more."

Instead of dialing down his own highly evolved sense of humor to fit socially constrained situations, Weems ultimately opted for a mate who is just as likely as he is to chuckle at a wake.

"We tend to laugh at things that other people don’t," Weems says. "And now, I’m starting to understand maybe that’s not so bad. It might no always be socially appropriate—but it might not always be bad."

Joe Maniscalco is a writer living in Brooklyn.