The philosopher Agnes Callard tells us that, sometimes, when she’s on a deserted road at night, she likes to walk on the double yellow lines. One evening, she decided to lie there in the middle of the road. She kept her arms pinned to her sides so that cars could pass on her left and right. A policeman approached, alarmed and confused. Was she drunk, high, suicidal? Callard explained that she had many reasons for being there; she wondered, among other things, what the stars would look like from the road’s perspective. Mostly, though, she wanted to know how it would feel. “Lying on the road is not a thing one does,” she writes, in an essay called “Unruliness.” When one is in an “unruly” frame of mind, such an act can be appealing for precisely that reason.

Callard is careful to distinguish unruliness from rebellion. By lying down in the road, she wasn’t critiquing the status quo or sticking it to the Man. Unruly people might flatter themselves as rebels, but unruliness is nothing so determinate—it’s just an unwillingness to play by the rules. It’s a near-neighbor, therefore, to perversity, a topic long central to theology and philosophy. A classic example of a perverse desire appears in Augustine’s “Confessions,” written around the year 400. Augustine recounts how, in his youth, he and his friends stole some pears. They weren’t hungry—in fact, they threw the fruit to the hogs. Instead, Augustine writes, their act was “gratuitously wanton, having no inducement to evil but the evil itself.” Accounting for his behavior, he concludes, “I loved the evil in me.” We still explain perverse behavior this way. Think of how Alfred describes the Joker in Christopher Nolan’s film “The Dark Knight”: “Some men aren’t looking for anything logical, like money. They can’t be bought, bullied, reasoned or negotiated with. Some men just want to watch the world burn.”

In 2009, in The Journal of Philosophy, the philosopher David Sussman published an article called “For Badness’ Sake.” In it, he defined perverse actions as those undertaken when our normal desire for the good—perhaps the moral good, or maybe just the narrower good of self-interest—is reversed. This state of reversal can be expressed as wickedness, as in Augustine’s case, but it doesn’t have to be. Sussman considers the appeal of truly awful movies, or of corpses and grisly accidents, and notes our interest in sniffing spoiled food even though—or perhaps because—we know it to be disgusting. He reminds us that it’s hard to see the “fragile beauty of icicles” without wanting to smash them, and points out that “most of us know what it is like to pick at a scab or worry a loose tooth simply because of the peculiar way in which doing so hurts.”

Perverse actors—I won’t call them “perverts,” since that word evokes distracting connotations—can also be creative or funny. I’m a psychologist, and some of my research involves interviewing young children and soliciting their opinions about various situations, such as moral dilemmas. Like everyone else in the field, I’ve learned that my data will always be a little messy because kids are so often perverse: they give silly answers for fun, saying the opposite of what they really think just because they can. Scientific papers have had to be retracted because of so-called mischievous responders. Researchers who study teen-agers have it worst. In one study, nineteen per cent of high-school students who claimed to be adopted turned out to be kidding. In another, ninety-nine per cent of students who said they used an artificial limb really didn’t.

Adults aren’t immune to the temptations of mischief. The blogger Scott Alexander points out that four per cent of Americans tell pollsters that they think reptilian aliens rule the Earth. (Another seven per cent say that they are “not sure.”) Alexander suggests that we should always keep in mind a “Lizardman constant” whenever we’re trying to estimate how many people honestly hold some bizarre-sounding view. Or consider that, when the U.K. government offered citizens a chance, through a poll, to choose the name of a new polar-research vessel, the winning choice by an overwhelming margin was “Boaty McBoatface.” (Officials decided to name the ship R.R.S. Sir David Attenborough, instead.)

Unruliness, perversity, pigheadedness—psychologists have long been interested in this bestiary of paradoxical thought and action. Perversity is a puzzle. It’s hard to explain, scientifically, what Edgar Allan Poe described as “the imp of the perverse.”

About ten years ago, the late psychologist Daniel Wegner made some progress in a paper, published in Science, titled “How to Think, Say, or Do Precisely the Worst Thing for Any Occasion.” It described those paradoxical moments when the effort to avoid a thought makes it more likely to bubble up into consciousness. Wegner was inspired by an observation made by Fyodor Dostoyevsky in an essay called “Winter Notes on Summer Impressions”: Dostoyevsky writes that trying not to think about a polar bear makes it more likely that you will think of one. Wegner investigated this phenomenon scientifically and found that trying not to think of a white bear could make white bears pop into subjects’ heads at a rate of about once a minute. (In some cases, after the experiments had concluded, white-bear thoughts kept returning for days.) Similarly, the psychologist Liane Lane and her colleagues have found that being told to keep something secret can, under some circumstances, increase one’s odds of revealing it. Other research has suggested that trying not to think about racial stereotypes makes people more conscious of them, sometimes to the point of distraction and anxiety.

Wegner proposed that such attempts at thought suppression involve two distinct mental processes. First, there’s a conscious and effortful system that works to create the desired outcome—for example, by finding something to think about that’s not a white bear. Second, there’s a part of the mind that remains alert to what’s being suppressed—it scans for white-bear thoughts so that they can be shooed away. Sometimes, especially if we are tired or distracted or inebriated, the workings of the second system seep into consciousness. Now you’re thinking of, and maybe talking about, just what you were trying to avoid thinking about.

Children, with their immature capacity for self-control, are particularly vulnerable to these effects. A friend of mine tells how his family made him a pie on his birthday, as a surprise. His young niece was repeatedly instructed not to reveal the secret, and she solemnly agreed. But, when he came into the house, she suddenly screamed, “There is no pie!”

Wegner’s approach explains these impulsive thoughts and actions in terms of failure of control. But it can’t make sense of the sort of behavior Callard and Augustine write about: perverse behavior that is deliberate, knowing, and strangely satisfying. The decision to lie down on the double-yellow lines doesn’t flow from a cognitive glitch. Rather, it’s a way of establishing oneself as an authentic and autonomous being. We might call it existential perversity. A person can ask: If I only do what makes sense, what use am I? Why is my consciousness relevant at all? The desire to exercise your autonomy might motivate you to turn against the expected, the reasonable, and the moral—to show yourself, and perhaps others, that you are free.

In the book “Midlife: A Philosophical Guide,” which The New Yorker’s Joshua Rothman reviewed last year, the philosopher Kieran Setiya tries to trace the deep connection between autonomy and perversity. Suppose, he writes, that you are facing a choice between A, B, and C. It so happens that you rank those possibilities in alphabetical order, preferring A to B and B to C. Now imagine that you also value having a choice. This might put you in the position—the absurd position, in Setiya’s view—of preferring the opportunity to choose between B and C to simply getting A, even though you know that A is better than either alternative.