Algorithms to Live By — Book Review

Precipice Cove
12 min readJul 20, 2020

The Computer Science of Human Decisions

Recommendation: Yes

Readability: 4/5

Enjoyment: 4/5

Content & Learning: 5/5

This book had an intriguing take on life’s problems and applied some nifty computer science solutions in creative, logically-sound, and enlightening ways, without coming across too technical nor too preachy.

The authors discuss the problems clearly and offer historical and current takes to the problem and the best current approach, while concluding with something thought provoking about oneself and the world we live within. It humbles us despite all the extra logical power we harness as a computer scientist as we take on the world in an algorithmic way.

I started this book quite excited to see how I can computer-science the shit outta life’s problems. I droned through the middle of the book in a little computer-science like fatigue, sort of like how my bachelor’s degree went in the middle years. I finished the book with a renewed appreciation of computer science and its realistic applications.

Let’s go over the noteworthy parts and how it pertains to my recent lifestyle.

There was a time when I spent my days sorting legal documents and compiling evidence for court. During this time, my primary duty was language-barrier induced. The law firm had insufficient Chinese language knowledge to gather the right names to the right files. And so, it was a pattern matching, sorting problem. Moreover, it was quite the headache of hoping things were ordered reasonably well and the number of papers numbered the millions, simply due to the magnitude of the problem and many names listed in Chinese and equivalently in English, it was impossible for any typical intern to sort this. And so, I went to work. Initially, one might think less of me as a computer scientist not even stopping to think over the problem before engaging.

But the truth is, I did not have enough knowledge of the problem and the reason I was brought on board. With minimal facts and guidance, I went to work sorting names and papers and documenting them into a Word file. And this is life in the law firm, really. But realistically, I did not want to do this for a million files, it felt like I was dealt a disciplinary sentence of million-page detention. Lo and behold, as I sorted, I spent my absent minded time thinking less about the reason I was there and more about how I can sort this problem out faster.

A few hundred pages in, maybe a few thousand, the idea dawned on me to write a python script that would translate the names and insert automatic texts for repetitive matches I found. Sometimes a name or two or a subject or a case type and its explanation was repetitively identical. Why type something twice? But because it needed human verification, I was slowed down by my single-tasked mind. I could only sort the items one at a time because that was the limitations of my one-track mind. My brain is multi-processed, but could not multi-process a sorting task. I don’t really think anyone can sort two decks of cards simultaneously. You can sort two decks of cards together, but you must stop and start separate threads in your mind in order to sort. You simply cannot sort two decks of cards simultaneously like a computer.

Hence, I decided it made the most sense to script it and then use small keywords I could type up as quick as possible, and the script would overlap the document again and insert entire sentences I would otherwise be Ctrl+C, Ctrl+V-ing, a task that even after a few thousand, anyone would notice how uselessly slow even that was.

And so, it goes to the introduction and some of the key topics of this book. It introduces to me the optimal solution when exploring options on a market. For example, when buying a house or buying a car, whether you’re on the buyer’s market, or renter’s market, seeking is a tedious task where you really only ‘get lucky’ in a busy market if you want a place. You essentially have to snatch the right property at the right time in less time than you would be comfortable pondering the option before another competing offer would beat you out with price + time.

And so, enter the idea of optimal exploration. Spend 37% of the time exploring new options without buying/renting/closing any deals. This is the concept of optimal stopping. It maximizes the efficiency of finding and judging the market so you learn the market and find your ideal place; while minimizes the chances of you landing a bad deal.

If you’re a month or two out from needing to close a deal (let’s say you have a deadline or a job start date and you need to move into a new area and get a car). Then optimal stopping basically teaches you to take 63% of the time trying to close a deal and 37% of the time window shopping. Eventually, after enough time has elapsed, you would reach the plateau area of the market prices and market options you have in on the table. So that, when the right house listing appears, you don’t even need to think much beyond sanity checks and damage reports to close this deal. You already, by then, know the market so well, you are near the least likely to land a bad deal and get ripped off.

So how is this related to the law firm sorting, you say? Well, the law firm example applies in this situation in one particular way. Remember when I said I was not sure what problem I was facing and was just thrown into the pile with little more instructions than ‘sort some Chinese names to English names’. Well, as I familiarized myself with the problem, my subconscious mind was doing the so-called 37% ‘market research’. Whenever I had absent minded time, it was wandering and looking for a more optimum solution.

My mind — wont speak for you, but it probably applies — often performs a new task sub-optimally and then after enough time/experience has been gained, I will start to ‘skip steps’ or ‘change the procedure’, do more of something and pay attention to less of something else. This is my mind optimizing itself automatically. Learning from this subconscious optimization behaviour, one can see I am in fact always shortcut-ing in some reasonable manner. That’s not a bad thing. And after reading about optimal stopping, I now know the skill I already have and how I can cross-apply it to something conscious.

I now knew how to better sort those documents, I started wire-framing some python code in my head that would label the cases faster. True to that, my last week at that job, I was sorting documents at twice the speed or better, not because the documents were easier — in fact, they were not, because the labelling got trickier and cases became even more scrambled after awhile — I had already started optimizing my work.

And so, for the managers out there, experience does matter. Yet its the quality of the worker’s experiences that matter the most. Who is optimizing their work, and who is stretching their hours out to maximize their wages? It’s all in the cards.

When should you risk a new option, when should you fall back to old and familiar? This is fundamentally the same problem. The book highlights the paradox of asking others or your spouse to choose a place to eat and the cognitive burden of imposing the question on the other. Where should we eat? is a heavy cognitive task. It draws far more brainpower to decide where to eat, because there’s many variables like: where did he/she eat last time? what are they craving? what’s nearby and convenient? what’s good to eat? what’s the weather? etc.

Whereas, if you already have an appetite or too lazy to travel far, you already have something instinctively in your mind. It’s better to present to your other half the dilemma between two or three choices rather than the open-ended question. Instead say, do you want pizza, burritos, or steak?

Now, your friends or spouse would be far more grateful you limited those choices from their tired out mind. We all know the question ‘What should we eat’ always appears after a task that tires the group or pair out. So why burden them further? Why pitch the problem into their arms?

Now do you understand why you get annoyed when they ask you? Or why you get those awkward silences or frustrations when they seem agitated at the mention of where should we eat? That’s because they’re too ******* tired to answer you!

Now that aside, the main point here was to draw on the idea of old vs. new. How often should one try new places to eat and how often should one go back to the familiar? How likely when we end up being served a bad meal?

This is the same problem as casino gamblers choosing slot machines. This is the same problem as making risk and reward, adventure or routine based decisions and it also corresponds to the young and risky and the old and safety type mentality of people based on their age. The older you get, the more likely you will prefer the familiar and take less risk. One, because you cannot risk your retirement funds, two, because you’ve seen enough of the world already, you just want to stay healthy and happy, or three, you just know the game too well.

The opposite is true for the young, they want to explore more options, they want to drink in the sensations of the world they’re only beginning to see and understand. They don’t mind some justice and social change because they can ride out the problems in between to see the glory days after. The old can’t do that. They have retirement to think about. They have to stay healthy and need the world to stay relatively consistent.

It’s really down to risk and reward vs stable and steady. A look-then-leap rule.

This is related to optimal stopping. How often should you try the new? 37% of the time. Or based on your age. Cause it also depends on how much time / many chances you have. Is it time to explore new options or exploit your certain gains?

If you’re younger, trying the new is likely not to hurt you as much as if you got the same experience or worse going back to the same place.

If you’re older, going back to the same place to relive the good times, you already have consistent experiences from these places, so why risk more?

If you take age out of the equation, then this youthful justice and old conservatism is no longer a factor. All you have left is optimal stopping.

Yes, going back to the familiar may not guarantee you a good meal, maybe there’s a different chef here. But if you go back to a place, get a poor experience, you’re less likely to go back again, but you still might. If you like a new place, you’re very likely to go back.

That’s an internal scoring system. But if you engage in optimal stopping, you will slowly explore more of the world and yet minimize the likelihood of a bad meal. You often go back to familiar meals that are highly likely to be cooked and prepared well, because you know this. If they suddenly dropped their quality, you would eventually catch on and not go back. Yet, every time you risk a new place, you risk it just enough (37% of the time), that you won’t catch too many ‘bad meals’ in your accumulated meals over time. And so, you end up quite happy over time.

For casino slot machines, find the ones that offer wins often. To predict which one is likely to yield a win soon, you have to watch it being played. I don’t gamble, I am not offering advice in gambling or offering advice to gamble, etc. But if you’re just having a good night in a responsible manner, you know the game better than me. Slot machines usually predictably offer winnings based on probability and dice rolls. It chance wins every now and then to entice players to keep gambling. Yet you commit too long to a losing machine, you lose too much to gain the eventual win; Yet you commit too little, you learn not enough about how often a slot machine offers a win. So it’s like, how often will my meal be good? Depends how consistent that kitchen offers you a ‘winning meal’. It’s really the same thing.

Before you panic and studiously try to study how to think like this for food or life, it’s likely you already do this at roughly 20–50% optimal stopping. Now you know where to narrow the your ballpark estimates. Enjoy~

Yet there’s more to see here. The scoring system you’ve generated in your head regarding good places and bad places is actually a statistical chart of how many times you ate well vs ate poorly at each of the places you’ve been to. Just how does this scoring system get used and how should you apply it so that you maximize your returns?

So to explore further the behaviour of explore and exploit, it’s really just two distinct move sets. You either win and stay, or lose and shift over to the next option.

And as you play, you discover more and more what you can optimize. And so you have only a finite set of resources, be it your time or your number of choices you can make, so you have the multi-armed bandit problem.

Surprisingly the best way forward at this point is to minimize your regret. You use confidence bound optimism to defeat regret. How can you gain confidence over time such that you minimize the times you are regretful. That is essentially the approach to these kinds of problems.

And of course, like number of chances, eventually you run out of time and have to make a choice sooner, so be aware of your upper bound. Eventually you are going to make a choice anyway, so optimize up to that point and then just exploit your gains the rest of the way.

During Obama’s reelection, the clicks of voting booths were analyzed with A/B testing to see voter experience.

Brain forest, cache miss

Memory recall slowdown occurs when there’s too much experience to shuffle through and you’re unable to cache it all. One side effect is memory blur, other side effect is memory cannot recall. Either way, the older and more experienced you get, the more likely your experiences will be too vast to allow your memory recall to correctly recover old memories, unless they are prompted instead.

Moreover, the pressure of time itself will always cause you to choose and commit to something sooner to avoid losing time.

Relaxation, the concept where you simply make it easier and make the criteria less strict in order to complete a problem. For example, in the travelling salesman problem, its impossible to optimize as you scale, so its nearly as good if a minimum spanning tree is constructed. By relaxing the criteria, something less optimum but reasonably good and functional can be found. In such a busy world, sometimes its just easier to keep things simple. And continuous relaxation can help solve a multi step complex problem.

Overfitting, the ears of a mammal having multiple bones was an idea of overfitting the structure of a mammal in order to function. Now there’s so many and it can be even more excessive. Such is the genetic mutations that help species adapt to changing environments. Perhaps nature tried too hard. Instead, for a quicker decision making, one can use early stopping to stop earlier than one would expect, or at random to stop early in order to guarantee something good without overfitting and ending up with a set that doesn’t solve the problem at scale or when its slightly different than expected.

Randomness, when do you leave things to chance. It’s alot like relaxation, overfitting, sometimes the best thing to do is to allow some randomness. This prevents bias but it also means that sometimes the most optimum is no better than chance. So why not chance something instead.

Prime Number encryption, monte-carlo, Miller-Rabin test, is a randomized algorithm. By sampling, one can improve the answer. Bloom filter has an error tradeoff space.

Hill climbing can help find local optimum, local max, but its like a lobster trap, which can keep the lobster stick in a local max.

Instead, either (1) jitter, (2) randomly restart; or (3) use metropolis algorithm (which is to occasionally accept a worse answer) to ‘wiggle’ your way out of a local optimum and maybe later on you find a bigger mountain.

How do you know when you’re done? Eventually, like all things, you run out of time and you simply accept the best answer you got by then.

In conclusion, computational kindness is the way to go. Let yourself handle a situation knowing the cognitive cost of something and simply rather than try to do the most complicated thing, choose some computational kindness and do something with more relaxation, and you’ll find you will overfit less, find a reasonably good answer.

One can then spend less time blocking, less time spinning in your cognitive gears, and more time to enjoy life.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Precipice Cove
Precipice Cove

Written by Precipice Cove

Just thoughts launched like shurikens across the optic fibres of our internet for no particular purpose than to put them somewhere.

No responses yet

Write a response