# Algorithms To Live By Book Summary

## The Computer Science of Human Decisions

Book by Brian Christian

Summary

Algorithms to Live By reveals how computer algorithms can solve many of life's most vexing human problems, from finding a spouse to folding laundry, by providing a blueprint for optimizing everyday decisions through the lens of computer science.

Sign in to rate

Average Rating: 4.67

## The 37% Rule: When To Stop Looking And Commit

The 37% Rule provides guidance on the optimal time to stop searching and commit to a particular choice, whether you're looking for an apartment, hiring an employee, or finding a spouse. In short, look at your first 37% of options to establish a baseline, then commit to anything after that point which beats the best you've seen so far.

To be precise, the optimal proportion to look at before switching to "leap mode" is 1/e, or about 37%. So if you're searching for an apartment and have 30 days to do it, spend the first 11 days (37% of 30) exploring options, then on day 12 pick the next place that tops your current best.

This algorithm offers the best chance of finding the single best option, though it will still fail a majority of the time. But it shows the power of establishing a "good enough" baseline before jumping on something that exceeds it.

Section: 1, Chapter: 1

## Why Silver Medalists Are A Lie

the 1800s, Lewis Carroll (of Alice in Wonderland fame) pointed out a flaw in single elimination tournaments, like those used in lawn tennis at the time. The problem is that the tournament format can only definitively determine 1st place. The person who loses in the finals could theoretically be the 2nd best player, but they could also be the 3rd, 4th, or worse. That's because they only lost to the eventual champion - if they had faced off against others, they may have lost those matchups.

As Carroll calculated, if player skills are evenly distributed, the odds that the 2nd and 3rd best players face off in the semi-finals is about 50/50. So awarding a silver medal to the finalist creates a lie half the time. The same is true of bronze medals determined by a 3rd place game. Single elimination formats simply don't provide enough information to rank anyone but the overall winner.

Section: 1, Chapter: 1

## Look-Then-Leap Vs. Threshold Rules

There are two main approaches to solving "optimal stopping" problems like hiring employees or buying a house:

- Look-Then-Leap Rule: Gather information for a set period of time, then commit to the next option that exceeds the best you've seen. This is the 37% Rule.
- Threshold Rule: If you have full prior information, simply set a predetermined threshold for quality and immediately take the first option that meets or exceeds it. No "look" phase needed.

The Threshold Rule only works if you have solid information on the distribution of options before you start looking. For example, if you know the distribution of typing speeds for secretaries, you can set a threshold and hire the first applicant who meets it. If you lack that information, the Look-Then-Leap approach is necessary to first establish a baseline.

In many real-world scenarios, from buying a house to choosing a spouse, we lack reliable priors. So some initial exploration, per the 37% Rule, is optimal before setting a threshold to leap for. The more uncertainty, the more exploration is needed before exploiting.

Section: 1, Chapter: 1

## Optimism In The Face Of Uncertainty

A key insight from the multi-armed bandit problem is the power of "optimism in the face of uncertainty." That is, when choosing between options where some information is known and some unknown, optimism is the mathematically correct approach.

Suppose you walk into a casino and see two slot machines. The first, you're told, pays out 20% of the time. The second machine's payoff rate is unknown. Which should you choose?

Rationally, you should try the mystery machine. That's because it COULD pay out at >20%, in which case it's the better choice. But you'll only find out if you try it. Mathematically, the expected value of an unknown option is higher than a known suboptimal one.

So in life, when facing uncertainty, choose optimistically - assume the best of a new person, place, or experience. Optimism maximizes your chance of finding something great. Pessimism can lead to overlooking hidden gems.

Section: 1, Chapter: 2

## When To Give Up On A Restaurant, Job Or Relationship

The explore/exploit tradeoff, also known as the multi-armed bandit problem, offers guidance on when to stop exploring new options and commit to the best known one. The optimal approach depends on the total length of time you'll be making decisions:

- Short time horizon (e.g. choosing where to eat on your last night of vacation): Exploit immediately by picking the best place you've been to already. Don't risk a bad meal to explore.
- Medium time horizon (e.g. choosing lunch spots in the few months before moving to a new city): Mix it up between exploiting old favorites and exploring to find new ones. Lean more toward exploring early on.
- Long time horizon (e.g. choosing jobs or relationships when young): Explore a lot, try new things constantly, don't settle down too soon. With decades of decisions ahead, finding a great option is worth many misses.

Section: 1, Chapter: 2

## The Gittins Index: Optimizing The Slot Machine Of Life

What's the optimal balance between exploring new options and exploiting known ones? Mathematician John Gittins solved this in the 1970s with the Gittins Index.

The Gittins Index assigns each option a score based on its observed results so far AND the uncertainty remaining in that option. Unknown options get an "uncertainty bonus" that makes them more attractive to try.

For example, suppose you have two slot machines, one that paid off 4/10 times, and a new machine you've never tried. The Gittins Index will recommend the new machine, because the uncertainty bonus outweighs the 40% payoff of the known machine. It COULD be much better.

Once you've tried an option enough times, the uncertainty bonus dwindles and its Gittins Index matches its observed performance. At that point you "retire" an option that underperforms.

Section: 1, Chapter: 2

## How To Arrange Your Bookshelf, And Your Life

What's the optimal way to sort your bookshelf? Sorting theory offers some guidance:

- Don't alphabetize. Alphabetical order takes more time to scan than the seconds saved in faster location. Especially if you're more likely to browse than look for a specific title.
- Don't group by category. In the age of search, sorting into genres, topics, or "like with like" is unnecessary. It adds more time than it saves.
- Do optimize for browsing. Put your favorite titles at eye level. Less accessed ones up high or down low.
- Do make it a "cache." Put the most recently read or acquired books in the most visible spot. They're most likely to be accessed again soon. Rotate books in and out.

The same principles apply to organizing your office, kitchen, or life.

Section: 1, Chapter: 3

## How Tournaments And Sports Rank Competitors

Many different tournament formats are used in sports to rank competitors, from March Madness to the World Cup. Each format is effectively a sorting algorithm.

The NCAA March Madness tournament uses a single elimination bracket. With 64 teams, it conducts 63 games total to (partially) sort the teams. It's similar to a merge sort, with successive rounds halving the remaining teams until a winner is crowned.

In contrast, a round-robin tournament where every team plays every other team would take 2,016 games to fully sort 64 teams. That's infeasible.

The World Cup uses a hybrid approach - a group stage where each group of 4 teams plays a round-robin, followed by a single elimination bracket. This balances the information gained from head-to-head matchups with the efficiency of elimination.

In general, more games or matches will yield a more reliable ranking, but also take more time. Tournaments trade off time and accuracy in their structure. But no tournament is perfect due to "noise" - an inferior team can beat a better on any given day. So even a full round-robin doesn't guarantee the "correct" ranking.

Section: 1, Chapter: 3

## The Periodic Table Of Sorting Algorithms

Computer science has categorized many sorting algorithms and identified the "periodic table" of how they relate. The key attributes are:

- Runtime: How long the algorithm takes, measured in Big O notation. Bubble sort is O(n^2), merge sort is O(n log n). This measures both average and worst case.
- Stability: A "stable" sort keeps items with the same key in the same relative order. An unstable sort might scramble them.
- Memory: How much RAM the algorithm uses. Merge sort is not in-place, so it requires O(n) extra space. Heapsort is in-place, requiring only O(1) extra space.

This "periodic table" helps programmers pick the right algorithm for a given job. For example:

- For general sorting, merge sort or quicksort are fast, but not stable or in-place.
- For mostly sorted data, insertion sort is simple, stable, in-place, but O(n^2) worst case.
- For huge datasets that don't fit in RAM, mergesort's O(n) extra space is infeasible.

Section: 1, Chapter: 3

## Deciding What To Keep

When deciding what to keep and what to discard, whether it's for your closet, your bookshelf, or your computer's memory, consider two factors:

- Frequency: How often is this item used or accessed? Things used most often should be kept close at hand. This is why your computer's RAM is faster than its hard disk.
- Recency: When was this item last used? Items used more recently are more likely to be used again soon. So the most recently used items should also be kept easily accessible.

Many caching algorithms, like Least Recently Used (LRU), primarily consider recency. But the optimal approach, as used by the human brain, balances both frequency and recency.

Section: 1, Chapter: 4

## The Surprising Benefit Of Clutter And Mess

While we often aspire to Marie Kondo levels of tidiness and order, there are benefits to some degree of clutter. That's because keeping things organized takes time - time that's wasted if you never access the items again.

For any storage system, like a filing cabinet or computer memory, there's an inherent tradeoff between "search" and "sort." The more time you spend organizing up front (sorting), the less time you'll spend trying to find something later (searching). But if you never look for the item again, that up-front sorting was all wasted effort.

That's why the optimal approach is to "err on the side of messiness." Only sort and organize things that you're confident you'll need to retrieve later. The less likely you are to search for something, the more clutter you should tolerate.

For example, don't bother organizing tax receipts that you'll never look at again. But do file away important contracts you may need to reference.

Section: 1, Chapter: 4

## How To Organize Your Office (And Your Hard Drive)

Many office gurus recommend organizing documents by category, like financial, legal, HR, etc. But this "group like with like" approach isn't actually optimal.

Instead, for physical filing systems, use the "Noguchi Filing System." Named after Japanese economist Yukio Noguchi, it dictates:

- Place all incoming papers in a single location, like an inbox tray.
- Whenever you need to find a document, search the pile from top to bottom.
- After you find it, place the document back on top of the pile.

This simple approach ensures that the most frequently and recently used documents naturally rise to the top, while rarely used ones sink to the bottom. No complex categorization needed.

Section: 1, Chapter: 4

## The Mathematics Of Multitasking

Trying to work on multiple projects at once feels productive, but mathematically it's highly inefficient. That's due to two fundamental facts:

- Switching between tasks wastes time. It takes time to mentally context switch, find the right documents, load the right programs, etc. Multitasking introduces "task switching costs."
- Delaying a task delays its benefit. If task A takes 1 day and earns $1,000 in revenue, while task B takes 5 days and earns $10,000, then doing A first unlocks value sooner. The order matters.

Scheduling theory has proven that the optimal approach to minimize lost time and maximize the time-weighted value of tasks is:

- Work on one task at a time
- Work on the task with the earliest deadline first
- Break ties in deadlines by doing the shortest task first

Section: 1, Chapter: 5

## How To Beat Procrastination With Computer Science

Procrastination feels irrational - why delay the inevitable? But mathematically, procrastination can be rational if you're solving the wrong type of scheduling problem.

Scheduling algorithms optimize for different things - some minimize the maximum lateness of tasks, while others minimize the total time to finish everything. If you're wired to knock out quick tasks first, you're optimizing to minimize task count.

But if some tasks are more important than others, then knocking out a bunch of easy items to trim your to-do list feels productive but isn't actually optimal. You're procrastinating on the tasks that matter most.

To beat procrastination:

- Assign each to-do a priority score based on importance
- Estimate how long each to-do will take
- Divide the importance by the time required
- Work on the tasks with the highest importance/time ratio first

This "weighted shortest processing time" algorithm ensures you're always working on the most important tasks relative to how long they'll take. It's the mathematically optimal way to get the most done.

Section: 1, Chapter: 5

## Why Teaching To The Test Is Effective But Dangerous

In computer science, "overfitting" means tuning an algorithm to perform well on the exact data set it's given, at the expense of working well on new data. A spam filter that blocks everything with the word "Viagra" might work great on one batch of emails, but fail when spammers wise up and switch to "V!agra" instead.

The educational analog of overfitting is "teaching to the test" - optimizing lesson plans to boost standardized test scores, at the expense of generalized learning and problem solving skills. It works, but leaves students ill-equipped to handle novel challenges.

The solution in machine learning is "cross-validation": testing an algorithm on data it wasn't trained on, to see how well it generalizes. If performance is high on the training data but crashes on the test data, the algorithm is overfit.

The same approach can diagnose when teaching to the test goes too far. Periodically give students a very different assessment, on material not covered explicitly in class. If those scores are much lower than on the standard tests, the curriculum may be overfit. It's preparing students narrowly, not broadly.

Section: 1, Chapter: 5

## Surprising Virtue Of Persistence And Ignorance

Suppose you arrive in a new city and see a long line outside a restaurant. Knowing nothing else, what does that tell you about the restaurant's quality?

According to Bayes's Rule, long lines are more likely to form for good restaurants than bad ones. Even with no other information, the line is evidence of quality. The longer the line, the better the restaurant is likely to be.

But now imagine you go into the restaurant and have a terrible meal. What should you believe now - your own experience or the line of people waiting? Again, Bayes's Rule says to weigh the evidence based on sample size. A single bad meal is a small sample. The long line reflects dozens of people's opinions. It should still dominate your judgment.

The same idea applies to product reviews, survey results, or any wisdom of the crowd. If your own experience contradicts the majority, trust the majority. Your own sample size is too small to outweigh the group. First impressions can lead you astray.

Section: 1, Chapter: 6

## How Many Trucks Does It Take?

During World War II, the Allies wanted to estimate the number of German tanks being produced each month. Intelligence officers simply looked at serial numbers printed on captured German tanks. If tank #1,242 was built in May and tank #1,867 was built in June, then they assumed 625 tanks were built in June.

After the war, data from German factories showed that the traditional intelligence estimates were off by a factor of 2.5. But the serial number analysis was off by only 1%.

Imagine a jar filled with marbles labeled from 1 to N. You draw a random sample of marbles, noting their numbers. How can you estimate the highest number N - the total number of marbles in the jar?

Statisticians showed that the best estimator is to take the highest drawn number and multiply it by (k+1)/k, where k is the number of draws. So if you drew 4 marbles with a highest number of 78, you'd estimate there were 97.5 marbles total.

The key is that missing marbles provide information, since they indicate the jar contains numbers you haven't seen yet. The estimator performs optimally by considering both what was drawn and what likely wasn't drawn yet, given the sample. A Bayesian approach outperforms one using the observed data alone.

Section: 1, Chapter: 6

## The High Cost Of Selective Attention

Imagine you're considering two slot machines to play at a casino. For machine A, you watch a dozen people play and 4 of them win. For machine B, you have no information. Which should you choose?

Most people avoid uncertainty and pick machine A. But rationally, machine B is more likely to pay off. Even though you have no data, the chances it pays off more than 33% are better than the chances it pays off less.

This is a direct implication of Laplace's Law: if you have no prior information, the probability of a positive outcome is (k+1)/(n+2) where k is the number of positive outcomes observed out of n attempts. For machine A, that's (4+1)/(12+2) = 36%. For machine B it's (0+1)/(0+2) = 50%.

Human attention, and media coverage, is drawn to the vivid and available, not the representative. This selective attention means that more media coverage of an event indicates that it's more rare, not necessarily more common. To be a good Bayesian, look for the silent evidence as much as the headline grabbing stories. Often what you haven't seen is as informative as what you have.

Section: 1, Chapter: 6

## The Danger Of Overfitting

When making predictions or decisions based on data, more information isn't always better. Trying to account for too many factors can lead to "overfitting" - building a model that matches historical data so closely that it fails when confronted with new situations.

Consider picking which route to drive to work. An overfit model would try to optimize based on every factor from past drives - weather, day of week, time of day, etc. A simpler, more robust model would just factor in a few key variables, like average traffic per route. It wouldn't match past data as closely, but would likely perform better on future commutes.

The risk of overfitting rises when:

- You have limited data
- The data is noisy or prone to errors or randomness
- You're trying to optimize for outcomes you can't directly measure

Section: 1, Chapter: 7

## When To Think Less

We often assume that more analysis produces better decisions. But when data is limited or messy, the opposite is true. "The amount of time you spend thinking should be proportional to the quality and quantity of the data."

- When possible outcomes are known but evidence is thin, go with your gut. Don't try to reason it out. If you're hiring and have little info on the candidates, just pick who feels right rather than overanalyzing.
- To make a big, uncertain decision, imagine the minimum information that would make you feel sure. Focus on getting that key data rather than amassing tangential details.
- Impose hard time limits on decisions. Use the "37% rule" - spend 37% of your time gathering information, then decide based on what you have. More time beyond that tends to create false certainty.
- Notice when you're putting more time into a decision than the stakes merit. Don't optimize the trivial.

Section: 1, Chapter: 7

## The Three Ways To Tame Hard Problems

Some problems are just intrinsically hard - no matter how cleverly we approach them, finding the perfect solution takes an impractical eternity. We handle challenges of unreasonable difficulty with three key techniques:

- Constraint relaxation: Temporarily remove some of the problem's constraints, solve the easier version, then figure out how to re-introduce the constraints. If scheduling delivery trucks is hard, allow trucks to teleport to their first stop. Optimize that simpler scenario as a starting point.
- Continuous relaxation: Replace discrete decisions with continuous ones. If assigning nurses to shift slots is hard, first let each nurse work fractions of shifts. Round to whole shifts later. The continuous version is often easier.
- Lagrangian relaxation: Convert hard constraints into a scoring penalty, so violating them is possible but costly. If product margins must be over 40%, put a huge point value on that threshold, but let solutions dip under it if they compensate elsewhere.

In each case, you start by allowing the impossible, which makes optimization easier. Then you figure out how to massage the solution back toward the original, harder problem.

Section: 1, Chapter: 8

## The Perfect Is The Enemy Of The Good

We often assume that if we can't find the perfect solution to a problem, we've failed. But for many hard problems, perfection is practically unachievable. This was a hard-won lesson in early computer science. Researchers spent kept proving that finding optimal solutions would take intolerably long in real-world scenarios, for challenges like scheduling, route mapping, and resource allocation.

They realized tolerating some error was better than endless computation toward an impossible ideal.The same standard applies to human problems:

- If you're planning a complex project, don't try to find the perfect schedule. Find one that meets key milestones and doesn't overload resources.
- If you're packing for a trip, don't endlessly optimizer. Satisfice with a packing list that covers all likely contingencies.
- If you're mapping a route, accept one that gets you to the destination in decent time. Don't compute every side-street seeking the absolute shortest path.

Bounded optimality beats impossible ideals.

Section: 1, Chapter: 8

## The Surprising Power Of Chance

We often see randomness as the enemy of good decision making, but in many contexts, randomness is a powerful tool for finding solutions. Many important computer science algorithms rely on randomness to efficiently get strong results.

- Randomized Quicksort, which pivots on random elements to sort faster than traditional versions
- The Monte Carlo method, which uses random sampling to estimate results too complex for direct computation
- Simulated annealing, which uses randomness to "explore" many possible solutions and zero in on good ones

What these algorithms grasp is that when a problem is too hard or complex for a perfect answer, an element of chance can actually make the best attainable answer more likely. Randomization helps the algorithms "bounce out" of dead ends and find creative possibilities.

If you're stuck on a complex problem, a random choice can shake you out of analysis paralysis and see options you were ignoring before. And when there are many unknowns, a random stab sometimes yields better results.

Section: 1, Chapter: 9

## How To Pick A Winner Fairly

Imagine you need to decide which employee to promote or which vendor to source from. You want to be scrupulously fair, but you're concerned that subconscious biases might creep in. Randomness offers an unexpected solution. Rather than agonizing to perfectly weigh every factor, you can:

- Set a clear quality bar for eligibility. Decide what minimum standards candidates must meet to be considered qualified.
- Make a binary yes/no decision on each candidate. No rankings, no attempt to suss out who's better by how much. Just "above the bar" or not.
- Among all candidates who clear the bar, choose one at random.

This process, while not perfect, removes many common flaws and biases from selection:

- Leniency bias (grading too easily) gets blunted because you're working off clear standards, not gut feeling
- Recency bias (overweighting latest information) is thwarted, since you decide on each candidate one at a time rather than comparing
- Implicit biases get less room to operate since all "above the bar" options are treated as equal

Randomness becomes a guarantor of equity rather than a bug.

Section: 1, Chapter: 9

## Why Kids Explore More Wisely

Children are endlessly curious, poking and prodding at the world around them. To adult eyes, it can look like unsystematic chaos. But there's wisdom in the way children explore. Psychologist Alison Gopnik argues children's exploration is more rational than it appears.

Children don't have rich mental models of the world yet. So spending lots of time reasoning from premises is less valuable to them than rapidly gathering new data. Since their beliefs are uncertain, exploring opportunistically tends to yield more knowledge than exploiting limited knowledge.

As we age and gain experience, our mental models firm up. We shift toward exploiting our accumulated wisdom rather than exploring to upend it. This makes us efficient - but also more likely to miss out on new possibilities.

When you're in an unfamiliar domain, there's value in embracing a childlike approach:

- Favor exploring over exploiting at first
- Interact and sample rather than introspect and plan
- Let randomness guide you to unexpected data
- Update beliefs rapidly as new information arrives

Section: 1, Chapter: 9

## The Three Secrets Of Successful Communication

At the heart of computer networking are three key principles that also apply to human communication:

- Packet switching: Information should be broken into small, discrete packets rather than sent in one big lump. In conversation, this means chunking ideas into sentences and pausing for reactions, rather than monologuing.
- Acknowledgments: Recipients should signal when they've received each packet, so the sender knows everything arrived. In human terms, backchannels like "uh huh" and "I see" are crucial for acknowledgement.
- Retransmission: If a packet goes unacknowledged, the sender should retry a few times before giving up and moving on. Socially, if someone doesn't respond to a question or comment, it's worth repeating or rephrasing once or twice.

Packet switching prevents overload, acknowledgments catch what's dropped, and retransmission fixes the remaining holes.

Section: 1, Chapter: 10

## How To Escape An Awkward Conversation

We've all found ourselves trapped in a conversation that feels like it's going nowhere, whether it's a stranger rambling on about their problems or a co-worker complaining for the hundredth time. How do you exit gracefully?

Computer science offers a surprising solution: exponential backoff. Here's how it works:

- Make an excuse to physically leave the conversation.
- If the conversation resumes when you get back, wait twice as long before your next exit.
- If it still continues, double your exit interval or distance moved yet again. And so on, until you're able to make a clean getaway.

Exponential backoff is how computer networks elegantly handle "collision" - when data from two sources arrives at the same time. Rather than keeping both senders transmitting (and colliding) indefinitely, exponential backoff has each one wait a little bit longer before retrying.

The same works socially. By absenting yourself for longer and longer intervals, or moving further and further out of range, you open up ever-larger windows for the conversation to naturally dissipate.

Section: 1, Chapter: 10

## How To Negotiate Like A Game Theorist

Imagine you're trying to make a deal, whether it's a job offer, a vendor contract, or even deciding where to go for dinner. You want the best terms for yourself, but you also need the other party to agree.

Game theory offers a powerful yet surprisingly simple prescription: be honest about what you want, and assume the other party will be honest too.

- If you're discussing salary at a new job, name the amount you actually want. Don't lowball for fear of setting the bar too high. Your employer will likely counter with what they're actually willing to pay. Now you can meet in the middle.
- If you're picking a restaurant with friends, just say where you really want to go. Assuming they do the same, you'll quickly converge on an option that works for everyone, rather than going in circles trying to mindread.

The key is to remember you're not in an antagonistic game. In most negotiations, both parties want a win-win outcome. Of course, this assumes the other party will be equally forthright. If you suspect bad faith or have a history of information asymmetry, all bets are off.

Section: 1, Chapter: 11

## Evolution Favors Forgiveness

The Prisoner's Dilemma is the most famous scenario in game theory: two prisoners are being interrogated separately. If both stay silent, they each get a short sentence. If one rats the other out, the snitch goes free while their partner gets a long sentence. If they both snitch, both get medium sentences. The rational play is to always snitch.

The question is, how can cooperation ever emerge in a dog-eat-dog world? The surprising answer: forgiveness. Computer simulations of evolutionary processes show that the most successful long-term strategies for iterated Prisoner's Dilemma games are "nice" ones - they start out cooperating and only defect if their partner does first. But critically, they also quickly return to cooperating if the partner starts behaving nicely again.

Tit-for-tat, but with reconciliation. Strict punishment of defectors, but no grudges. Why does this work? Essentially, being forgiving avoids an endless cycle of retaliation. One party's selfish action doesn't lead to an arms race of increasing betrayal.

This sheds light on the evolutionary origins of seemingly irrational human behaviors like empathy and mercy. Natural selection can counterintuitively favor "nice" strategies.

Section: 1, Chapter: 11

## Related Content

## Rebel Ideas Book Summary

Matthew Syed

Matthew Syed reveals the vital ingredient missing from our understanding of success: cognitive diversity. Rebel Ideas shows how bringing together different insights, perspectives and thinking styles turbocharges creativity, problem-solving and decision-making, to improve performance in today's complex world.

Matthew Syed reveals the vital ingredient missing from our understanding of success: cognitive diversity. Rebel Ideas shows how bringing together different insights, perspectives and thinking styles turbocharges creativity, problem-solving and decision-making, to improve performance in today's complex world.

Psychology

Innovation

Business

Leadership