The Anxiety Algorithm

I learned that courage was not the absence of fear, but the triumph over it. Nelson Mandela

You started a company a few years ago. The company now has sales, employees, and some buzz.

I ask you, “Would you rather have the business you have now, or had 2 years ago?”

“Now, obviously,” you say. “Look how much bigger we are!”

“Ok, were you more anxious then or now?” I ask.

“Definitely more anxious now,” you reply.

I've had a conversation like this with dozens of different founders, and I experienced the feeling firsthand running Hipmunk. I would overreact to minor problems, ignore major ones, bristle at useful suggestions, lose sleep, and eat poorly. Other founders take excessive risks, burn out, alienate employees, or become addicted.

Like a skin rash, anxiety can be indicative of a transient minor issue or a serious medical condition. (If you’re not sure which applies to you, you should consult a trained professional.)

And yet, many founders also credit their anxiety for giving them the drive and creativity to succeed.

I believe it’s possible to have more of the good parts of anxiety with less of the bad. To see how, I’m going to share a perspective that’s been helpful for me and many founders I’ve shared it with: seeing anxiety as an algorithm.

For context, let’s first talk about our biology.

The Immune System

Over the course of a few months, we on average encounter more than a thousand different kinds of bacteria and viruses. Once in a while, we get sick. But it’s remarkable how rarely that happens (on average only once every few months); our bodies successfully defend us from roughly 99.9% of the pathogens we encounter.

The way we survive so well is because of our immune system. You can think of our immune system as running an algorithm for protecting us against threats[1]:

  1. Detect a bacterium or virus
  2. Determine whether it’s dangerous
  3. If it’s dangerous, attack it

Amazingly, our immune system doesn’t just defend us from viruses we’ve encountered—it defends us from novel viruses. And, per steps 1 and 2, that means it’s able to uniquely identify viruses no one has ever encountered before.

In order to identify a virus, our immune system recognizes shapes (called antigens) on the virus's surface. Bottom line: our immune system has receptors to match most antigens that could ever exist.

If that sounds like a hard algorithm to write, it’s because it is. For decades biologists couldn’t figure out how our immune system did it. The person who discovered the answer—Susumu Tonegawa—won a Nobel Prize for it.

In short, Tonegawa's insight was that our immune system builds receptors at random, over and over, until it's built billions.

The way it does this is by shuffling up some chunks of DNA, building the resulting receptor out of proteins, and repeating, as shown in this video:

I think of this as an algorithm exploring a space of all possible receptors, starting with one at random:

A matrix of possible receptors has just one point filled in
First receptor created at random

Then progressively creating more random receptors:

The matrix of possible receptors is partway full of random points
More random receptors created

Until it’s created almost all of them:

The matrix of possible receptors is mostly full of random points
Most random receptors created

Said differently, this algorithm “imagines” most microscopic threats by imagining one random threat at a time.

The Immune System of the Mind

In the real world, there are many threats besides microbes: someone stealing all your money, running you over in a crosswalk, poisoning your food, drifting into the wrong lane of traffic, etc.

A cow would have no success surviving these threats, but people do. How could you program a robot’s algorithm to do just as well?

First, you'd have to give the robot a way to recognize different situations as different. One way a robot could recognize a scenario is by having experienced it before. “Cars usually drive fast around that blind curve,” the algorithm might observe. And then next time, the robot would know to cross elsewhere.

But if you really want to give the robot survival superpowers, you'll give it the ability to recognize scenarios it's never directly encountered before—even scenarios no robot has ever encountered before.

Anticipating novel futures is just like what our immune system does. And that algorithm can serve as inspiration here:

  1. Take some little snippets of possible futures
  2. Shuffle them up at random
  3. Whatever results is a version of the future the robot might encounter someday
  4. Repeat the process over and over until the robot has imagined everything it can
  5. Now the robot has a space of possible futures it might encounter

Of course, good outputs rely on good inputs, so the choice of snippets is crucial.

You could try programming a list of everything a robot could encounter. But robots are going to live in different places, with people speaking different languages and observing different customs. So listing all possible snippets is both impractical and will lead each robot to imagine futures that are mostly irrelevant to its particular environment.

Best, then, to hard-code just a few snippets: the ones useful for every robot (e.g. the idea of the rechargeable battery it uses). And then to augment those snippets with ones relevant to each particular robot’s environment.

For example, suppose the robot has a boss named Chelsea; Chelsea would be a snippet. Likewise, if the robot reads about road construction in its neighborhood, the construction project would be a snippet. If the robot hears about a robot getting fired for being late to work, it would have snippets for “being fired” and “late to work.” And so on.

Together, these snippets would be recombined to form imagined futures like:

  • Road construction leaves the robot unable to receive a delivery of a needed new battery
  • Road construction makes the robot late to work and Chelsea fires the robot
  • Road construction makes Chelsea late to work and Chelsea gets fired

If you wanted a robot to survive, you'd program it to watch scary movies of the future
Snippets form scary movies; the robot watches to anticipate danger

Now look what you’ve done: you’ve programmed anxiety into a robot, because doing so helps it survive.

Imagining the Human Algorithm

Humans aren’t robots, but if you imagine our brains “running this algorithm,” some things become easier to reason about.

Why everyone has some anxiety

The ability to imagine future scenarios has provided a major survival advantage. You don't have to try risky things to learn whether they're actually dangerous—your brain can simply watch hypothetical scenarios like movies and and learn lessons from watching.

One consequence of experiencing imagined futures as movies, though, is that the scary futures feel scary. And because this algorithm is so useful, we spend a lot of time watching scary films in our imagination.

Said differently, fear is a feature of anxiety that kept our ancestors safer, so all of us feel anxious sometimes.

Why initial success makes you more anxious

When you first start a company, the number of ways to fail is relatively small:

On day 0, you can only imagine a small number of ways to fail
Threats you can imagine on day 0

When your startup gets traction, the number of possible distressing futures explodes:

2 years in, you can imagine a terrifying number of ways to fail
Threats you can imagine in year 2

After all, an employee can't quit if you don't have any employees; a board member can't fire you if you don't have a board. As success takes root, new snippets proliferate for your anxiety algorithm to weave into a random tapestry of possible failures.

Your sense of responsibility amplifies the anxiety. The movie in your imagination isn't just your revenue falling; it's also your company not being able to raise more money, you shutting the company down, your employees hating you, your social stature falling, and your significant other leaving you. That's a tough movie to watch.

Why founders are especially prone to anxiety

Different people seem to have different levels of imaginativeness. In my experience, early-stage founders are outliers on the high end, because they're in the business of imagining things that have never been done.

But the very imaginativeness that enables them to see new opportunities also reveals paths to failure that other don't notice[2]. Seeing these futures can be a blessing (creativity) or a curse (anxiety).

Why change makes employees anxious

Leadership often entails changing things—cutting a budget for a team, say, or hiring a manager for an employee who previously reported to you. Think of the people affected by the change as running the anxiety algorithm in their heads: they're watching various movies of how the change could play out.

Many of these movies are scary! When you cut an employee's budget, for example, she could worry that her opportunities for promotion are lessened, or that it's a sign you're considering cutting her job altogether.

This is why changes are hard on your employees in the short term, regardless of whether they benefit in the long term.

Calming Anxiety

The good news is that the algorithmic model of anxiety also points the way to several techniques for reducing anxiety without sacrificing creativity.


If you suffer from nightmares, one solution is to stop sleeping, but a better one is to recognize that nightmares aren’t real life.

It’s just as true for daydreaming. Anxiety commandeers our senses and emotions because that's how it prepares us for possible dangerous futures, not because those futures are real.

Developing a habit of recognizing thoughts as distinct from reality has been shown to reduce anxiety. For more information on this approach see here.

Decisiveness, routines, and relationships

Smart founders reduce the kinds of snippets that create anxious distractions.

This starts with being decisive. Some decisions are thought-intensive but nearly irrelevant to your startup’s success. If you often spend an hour shopping flights to save $10, for example, try reminding yourself of the unnecessary snippets you’re generating.

It also helps to create routines that reduce the need to decide on minutiae. Steve Jobs famously had just one outfit.

Most of all, difficult relationships are a petri dish of new snippets. In addition to the anxiety of the relationship itself, your anxiety plays you elaborate movies of how bad it could be to end it—to fire the employee who’s creating trouble, say, or to break up with the lover you’re not really in love with.

As with most aspects of startups, it’s not the obviously awful things that are the problem (you solve those because they demand attention). The problem is the mediocre things that never quite become crises, which generate endless snippets without demanding resolution.

You’ll be less anxious if you make a list of your mediocre personal and professional relationships, and prioritize either improving them or ending them.

Setting expectations

Disappointment feels bad, and our anxiety works hard to anticipate it. But disappointment is always relative to expectations, and setting expectations differently can preempt disappointment and reduce anxiety.

“The default is failure” is the truth for early-stage startups, and reminding yourself of this daily can mitigate the anxiety of failure. “Most new ideas aren't good businesses” is a useful reminder when hunting for product-market fit. “Many new hires don’t work out” is both true and a balm when you worry you made a bad one.

Final thoughts

Most successful founders go to great lengths to conceal their anxiety in public. This used to make me feel worse, because having anxiety felt like proof of my not belonging to the Successful Founders Club.

Then I learned that all founders experience anxiety.

When you feel surprised at how anxious you are about work, remind yourself, “I have chosen a line of work in which anxiety is normal.” And know that it's not the presence of anxiety that separates successful founders from others; it's how they deal with it.

In my next post, I share some color on why different founders get anxious about different things.

Thanks to my pre-readers for their helpful comments: Andrew Wansley, Brad Feld, Brian Christian, Cameron Yarborough, James Somers, Kelly Peeler, Ken Zolot, Nancy Hua, Nikhil Srivastava, Sanjay Sarma, Shengwu Li, Shirley Wang, Taylor Beck, and Zak Stone. And thanks to David Jouppi for the illustrations.

Sign up for updates


  1. More accurately, it’s our adaptive immune system that works this way. ↩︎

  2. This is true for other creative professions, too. Designers, engineers, data scientists, marketers, and product managers begin their work in the realm of the imaginary. And outside of startups, many other professions reward imaginativeness: artists, writers, musicians, etc. ↩︎