This is the third essay in the Anxiety Algorithm series. Click here to read Part 1 and Part 2.
When I ran Hipmunk, I noticed a pattern in how events affected me. When things were going smoothly and something good happened, I felt good about it. But when something bad happened, like our sales missing expectations (or a bad night’s sleep), good news didn’t seem as good.
Over time I came to see this as the result of a couple algorithms running in my head. And then I noticed those algorithms explained a bunch of other quirks, like:
- Why I get worked up so much faster than I calm down
- Why I spend so much time in my head when I’m stressed out
- Why the stock market goes down faster than it goes up
- Why meditation reduces anxiety
- Why some people are more anxious than others
I'll walk through the algorithms first and show how they answer these questions. Then I'll show how I’ve applied this framework to reduce anxiety, and how you can do the same.
Imagine you're programming an autonomous robot. You want to maximize its odds of survival, but the robot only knows the likelihood anything it encounters is dangerous.
It’s much riskier to ignore real threats than it is to attack non-threats by accident. So the robot should attack things with even a small likelihood of danger. I call this threshold probability the Paranoia Line, and illustrate it like this:
With this Paranoia Line, the robot attacks anything with even a 9% chance of being dangerous, and survives 95.4% of the time overall. If people are designed the same way, it’s no wonder we get worked up about so many small things.
The Futility of Optimality#
Things get more complicated when the odds of danger change. Perhaps normally the robot has a low chance of being fired from its job, but if the stock market crashes, layoff risks go up, and it should start worrying.
Different environments thus have a different distribution of threats. That, in turn, changes how often the robot should attack:
A Flight to Safety, with Layovers#
No robot can ever know exactly how dangerous something is—but experiences are still informative in relation to each other. “This chainsaw seems scarier than anything I’ve seen besides a thunderstorm,” the robot might think, even if it doesn't know whether it's 99.3% or 99.7% dangerous.
Let’s define the Concern Zone as anything the robot thinks is dangerous enough to worry about. Then it can tune its Concern Zone as it lives and learns:
- Assess how dangerous a stimulus is relative to past experience
- Attack it if it’s within the Concern Zone
- If the decision results in harm, make the Concern Zone bigger or smaller, as appropriate, to reduce the risk of repeating the mistake
This animation shows the algorithm in action (the Concern Zone is in red):
This algorithm works under more complex circumstances, such as when the robot’s perception is inaccurate or the environment varies with time:
The Concern Zone gets bigger quickly and smaller slowly, because when a real threat slips through the cracks, it suggests that the environment may have become suddenly more dangerous. I define the Reactivity Ratio as the ratio between how much the Concern Zone grows and shrinks. By running simulations, I found a Reactivity Ratio of 15 ensured a 95% survival rate—almost exactly as good as the 95.4% for a perfect Paranoia Line.
This helps explain why people are wired to get worked up dramatically faster than we calm down: if we didn’t, we’d survive less often. You can play with the simulation code here.
The Attention Portfolio#
The robot’s attention determines which stimuli it experiences, but how should it invest its limited attention? Ideally, in an “attention portfolio” that keeps it safe over its life—combining a wariness of current danger with an eagerness to learn and grow.
This balancing of risk and growth mirrors a financial concept known as Modern Portfolio Theory. For a given level of growth, you can minimize risk by combining multiple investments with different, uncorrelated risks.
Thankfully, the robot has three different places it can get inputs from, each with different risks and rewards:
The robot’s direct experience. Experiences accurately reflect how safe or dangerous the robot’s environment is, because they’re drawn directly from it. But if the robot solely relies on its own experience, it might naively do something new that seems safe but that others knew was actually deadly (like plugging itself into a wall charger of the wrong voltage).
Scenarios the robot imagines. Imagination can be helpful for inferring what dangers the robot ought to prepare for. But if the robot spends too much time imagining based on old experiences, it risks reinforcing an out-of-date Concern Zone.
Experiences other robots have talked about. Listening to others can raise awareness of new dangers, but too much risks delusion. A fascist robot politician might stoke paranoia; a fraudulent robot CEO might stoke complacency to unload stock before others discover the fraud.
Your robot, therefore, should invest its attention across all three, and re-allocate its attention as the risks and rewards of each change.
Understanding the Human Algorithm#
Everybody got a pistol, everybody got a .45
And the philosophy seem to be
At least as near as I can see
When other folks give up theirs, I'll give up mine Gil Scott-Heron
Humans aren’t robots, but if you imagine our brains “running these algorithms,” some things become easier to understand.
Why it's normal to be in your head#
When the world seems safe, it offers large benefits with low risk. But when the world seems dangerous, the attention portfolio suggests it's safer to think instead of explore. I’ve noticed when I’m stressed, I tend to get stuck in thought loops instead of risking making hard decisions.
Why fear is contagious#
Our attention is partly invested in other people's words and actions. For example, when people flee from a fire, passers-by instinctively know they should also stay away.
This is an example of reflexivity, in which cause and effect loop back on themselves, and it's amplified by a high Reactivity Ratio.
Society is full of contagious concern: bank runs, stock market crashes, escalating relationship conflicts, and retaliatory violence. I notice it in myself whenever I hold a grudge.
Once trust is lost, it takes much longer to rebuild, because a high Reactivity Ratio make us slow to accept that the world has gotten safer.
Why some people have more anxiety than others#
An appropriate degree of concern increases survival, but what’s appropriate is situational. People from safe environments are better off if they’re less concerned, but people from dangerous environments are more likely to survive (and reproduce) if they’re very concerned, as I show below. Iterated over generations, this selection causes significant genetic variation, and indeed, people are born with different predispositions to anxiety.
And it’s not just in our genes. Research suggests that children of Holocaust survivors experience more lifetime psychological stress as a result of epigenetic alterations (changes that determine which genes get expressed) from their parents. This research is nascent, but it would provide a real survival advantage to receive an appropriate Concern Zone directly from parents’ bodies.
People also internalize the appropriate Concern Zone from life experiences. Children who are neglected or beaten have dramatically higher risk of anxiety later in life; soldiers who face non-stop threats for months have much higher risk for PTSD. Traumatic experiences are like a mega-dose of damaging inputs, jacking the Concern Zone to the highest extreme.
Why anxious people are often drawn to stressful situations#
For every environment there’s an optimal Concern Zone, and vice versa.
To demonstrate this, imagine everyone has a different Concern Zone, fixed and unchangeable throughout life. But suppose they can all choose their environments to maximize survival. Here are four permutations:
Someone with low concern (top row) survives more often in a safe environment (94% of the time) than in a dangerous environment (93%).
However, someone with high concern (lower row) survives more often in a dangerous environment (97%) than a safe environment (93%).
In real life, we have some control over our Concern Zone, but not full control, because of our genes and life experiences. And while it’s possible to notice this tendency or even lower your Concern Zone deliberately (as I outline next), most people don’t.
The consequence: we tend to pick our work and relationships to mirror familiar levels of stress. I know I wouldn’t have found the stress of running a business tolerable if I hadn’t been acclimated to high stress in high school and college.
I see the sun, it shines a little brighter today
‘cause I decided to find the peace inside, rearrange my mind Incognito
Thankfully, these algorithms also suggest techniques for reducing anxiety. The Concern Zone shifts based on how frequently you experience things that feel like “suffering damage” vs. “surviving unscathed,” and you can direct attention differently to change the balance.
Picking a more positive environment#
Though we default to environments that are familiarly stressful, it's possible to override the defaults.
For example, when I noticed myself getting overwhelmed at work, I started scheduling half-hour breaks on my calendar so that I wouldn't end up with days of 20 back-to-back meetings. Outside of work, I stopped investing time in some non-profits that felt rudderless, and invested more time in exercise and learning new hobbies.
Changing Internet usage#
On balance I’m glad the Internet exists. But I suspect that one day we’ll look at today’s Internet the same way we look back at when Coca Cola contained cocaine.
News is informative, but the subject matter is relentlessly negatively biased. Many social services keep score (e.g. Instagram likes, dating app matches), creating a subtle pressure to spend more time. Because of the downsides, I avoid checking these kinds of services more than once a day.
By contrast, reading about big ideas and being in certain online communities offer great positive input. I enjoy spending time in WhatsApp groups of founders I’ve worked with; for some people, Reddit support groups serve a similar purpose.
Finding supportive people#
When I ran Hipmunk, there were stressful times where changing my environment or disconnecting weren’t options. The best source of positivity was talking to other people who could relate.
Supportive people can include friends, romantic partners, relatives, peers, mentors, support groups, therapists, and coaches. (In the most extreme cases, there’s the National Suicide Prevention Line.)
Positivity is contagious like concern, but it takes more positivity to move the Concern Zone an equivalent amount. So when I’m stressed, I make supportive check-ins more frequent.
Giving yourself more positive inputs#
You can also give yourself encouragement and understanding on a regular basis. This is the notion behind self-compassion. At first this sounded cheesy to me, but sometimes strong cheese is what goes best with a bitter ail.
Because anxiety feels bad, it’s natural to meet it with negative feelings like dread, judgment, and disdain. I’ve lowered my Concern Zone by instead meeting anxiety with neutral inputs like deep breaths, or positive inputs like gratitude (thanking anxiety for trying to keep me safe).
Many of the negative inputs we receive come from the scary futures we imagine, but there’s no rule that you have to process a scary thought as something to be interpreted negatively. An alternative interpretation is neutral: thoughts are outputs from a randomization algorithm running in your head.
Using this approach is like running mental code in debug mode with breakpoints, and it’s something I improved at with mindfulness practice.
Alternatively, you can notice when a scary movie starts playing in your head and choose to redirect attention to neutral or positive thoughts. This requires “self-thought-control” (i.e. focus), and that, sadly, doesn’t come pre-installed with our default OS.
I tried to build focus with meditation, but it did not go well at first. Being unable to focus felt like failing the meditation test. My new attitude on meditation is to “try to try to focus,” along with having greater appreciation for the challenge. My focus has improved, and now I regularly interrupt unpleasant thoughts in the opening credits.
Running Hipmunk, my biggest worry wasn’t failure, but rather indefinite uncertainty. I worried that in a year I’d still have no idea whether things would work. In short, I was anxious that I’d continue being anxious.
I’ve since learned that anxiety is a decent way to survive, but a terrible way to live.
So I upgraded my mental software. Initially, this felt uncomfortable and unfamiliar, because my concern hadn’t adjusted. But with time and practice, my mind internalized that my environment had actually become safer, and my concern re-calibrated down.
When I imagine lots of futures and believe most of them are frightening, I’m anxious. When I keep the imagination and ditch the fear, I’m creative. My work gets better, and my mood does too.
After years of skepticism and stress, I've changed my mind. A mental software upgrade takes work, but it's worth it.
Thanks to my pre-readers for their helpful comments: Andrew Wansley, Brian Christian, James Somers, Cat Meyer, Christopher Thorpe, Danielle Strachman, Kelly Peeler, Nancy Hua, Shirley Wang, Steve Huffman, Taylor Beck, Uri Lopatin, and Zak Stone. And thanks to Yuval Haker for the illustrations.
Which is the best survival probability it can hope for, under certain assumptions outlined here. ↩︎
This approach of iteratively guessing the value of an unknown quantity is the core of Kalman filters. The algorithm I describe here resembles a Kalman filter for guessing the threat level of the environment. However, I chose to sacrifice a (little) bit of the accuracy of a Kalman filter in exchange for a much simpler algorithm whose parameters have more obvious analogues to human experience. ↩︎
For this animation, I added normally distributed random noise to the real threat level (limiting the sum to a minimum of 0% and maximum 100% so it couldn’t go off the graph), which is the difference between the black and white triangles. ↩︎
For example: the risk-assessment system could be trained on bad or stale data, it could be accurate for inputs it encounters often but inaccurate for ones it rarely encounters, there could be a bug in its code, or the inputs to the risk-assessment system (e.g. hardware sensors) could be biased. ↩︎
It’s counterintuitive, but true, that the optimal Paranoia Line remains static regardless of how the environment changes. Recall that the Paranoia Line deals with absolute threat likelihoods, whereas the Concern Zone deals with relative ones. Every time the robot faces a new situation, its survival odds are determined by the payoff matrix here. Suppose it encounters something that’s 80% likely to be safe. If it doesn’t attack, it has an 80% chance of being right (in which case it always survives) and a 20% of chance of being wrong (in which case it dies), resulting in total survival odds of 80%. By contrast, if it attacks, it has a 20% chance of being right (in which case it always survives) and an 80% chance of being wrong (in which case it survives 90% of the time), for a total survival likelihood of 20%+80%*90% = 92%. Therefore it should attack anytime it encounters something 80% likely to be safe—whether these encounters happen often (as in a safe environment) or infrequently (as in a dangerous environment). The same principle holds true for any given threat likelihood, which is why the optimal Paranoia Line depends solely on the payoff matrix and not on the distribution of threats. ↩︎
This is “informative” as defined by Claude Shannon, meaning “surprising.” And while this helps explain why a big Reactivity Ratio makes sense in general, but precisely how big it should be depends on multiple parameters. For example, if you pick too low an initial Concern Zone, the robot will need a higher Reactivity Ratio to compensate so that it quickly increases its Concern Zone to the optimal level. If the robot’s life is nasty and brutish (as reflected in being in a danger-skewed environment) and short (as measured by a low number of things it encounters in its life), a too-low initial Concern Zone requires an extra-high Reactivity Ratio to compensate. ↩︎
If finding this number empirically rubs you the wrong way, by all means work out the closed-form solution and email it to me; I’ll update this footnote to link to your solution. Here's a starting point: suppose the Concern Zone shrinks by an amount x and expands by an amount xR (where R is the Reactivity Ratio), and growing happens z percent of the time while shrinking happens w percent of the time. z equals the percentage of the time the robot encounters a false negative (approximately 0.4% in a uniform threat distribution with a Paranoia Line of 91%, from the previous essay), and w equals the percentage of the time the robot encounters a false positive (approximately 4.1%). Once the robot has “found” the Paranoia Line, we want it to stay there, which means that the expected movement right and left from there should be equal: xw = xRz, and therefore R = w/z, or 10. This solution, however, is only valid for infinitesimal values of x (so that it stays close to the Paranoia Line), infinite iterations (so that for essentially all iterations the robot has already “found” the Paranoia Line), and a uniform, static threat distribution. The solution will be more complicated otherwise. ↩︎
We tend to think about “spending” time, but because everything we encounter nudges our Concern Zone, our decisions about time are also an “investment” that shape our view of how safe our environment is. ↩︎
This insight garnered a Nobel Prize. ↩︎
This is important because no robot can know whether it’s fundamentally off-base about dangers by simply relying on its own experience and imagination (the latter of which is also a function of its experience). Other robots serve as a distributed data store about the threat level of stimuli in the world. ↩︎
Alternatively, another robot could simply have experienced life in a very different environment and share that experience to the best of its recollection (“We walked to school 10 miles in snow, uphill both ways”). ↩︎
Research shows people feeling anxious ruminate more. ↩︎
My friend shares a first-hand example of how this played out: “You get to thinking about whether your boyfriend left the stove burner on when he made you breakfast earlier at your house, and pretty soon you’re freaked out that your whole house might have burned down, so you call him and he says he’s sure he didn’t leave it on—as sure as he can be, since nobody watches themselves do such a thing, and we all cook so routinely that the individual memories blur. This answer just makes you think you can’t trust your partner and that maybe you should break up with him, but if you do, won’t you be alone and what if you don’t meet someone else who tolerates your neuroticism, you might be alone forever, and what if this week long meditation retreat you’re headed to is unbearable precisely because you’re going into it in a frantic anxious state of uncertainty?” ↩︎
Reflexivity can even arise within an individual. If a robot searches for a job for 2 months and can’t find one, it may imagine never getting hired again. This scary thought increases the robot’s Concern Zone, which makes it spend even more time in its head instead of risking further rejections. Eventually, the robot gives up searching—and its giant Concern Zone becomes self-fulfilling. ↩︎
Indeed, knowing the environment has become dangerous is so valuable for our survival that we pick up on it rapidly even from non-verbal cues. ↩︎
All of these consequences can be bad for humanity, but evolution also acts at the level of individuals. When benefits are concentrated to you and the harms are distributed to everyone else—and everyone else is acting selfishly—it makes sense you’d try to withdraw your cash from the bank before everyone else does. ↩︎
Other studies indicate similar results from being a child of an American Civil War solider or a child of someone facing persistent discrimination. ↩︎
Less dramatic stresses expand the Concern Zone, but the effect is less dramatic—though an accumulation of many small stresses could have similar impacts to one medium-sized one. ↩︎
In fact, there’s an even more general result: given two of a) a threat distribution, b) a Paranoia Line, and c) a Concern Zone, you can calculate the third. The reason is that the Concern Zone is the environment’s Cumulative distribution function (cdf) evaluated at the Paranoia Line. (You can verify this visually in the graphs earlier.) You can also demonstrate this to yourself by downloading the simulation code: fix the initial Concern Zone to a value you choose, prevent the Concern Zone from changing, and then vary the threat level of the simulation by picking different slopes for the threat distribution. ↩︎
“If it bleeds, it leads” has been a saying since before the Internet. These days, algorithms cherry-pick the stories most likely to get each of us riled up; those are the ones that keep us paying attention and clicking for more. ↩︎
While Facebook can be a way to connect with distant friends, research has shown that it also generates significant anxiety. Seeing the polished, curated things that other people post can give the impression that their lives are all great—and because disappointment is relative to expectations, this can raise negative thoughts about why our lives aren’t as good. Even text messaging can raise anxiety. It’s apparent every minute that someone hasn’t replied, and our minds are experts at imagining scary futures based on new information. ↩︎
I also turned off notifications for these apps. And since even the most positive online interactions happen just a click away from negativity, I also take a day each week completely off the Internet. ↩︎
You can also choose to process thoughts in other ways. When there’s a situation that’s stressing me out, I’ll sometimes close my eyes and imagine the situation as a person; I’ll look into his eyes and ask what he’s really trying to tell me. ↩︎