Algorithms to Live By: The Computer Science of Human Decisions
Rate it:
Open Preview
Read between November 19, 2023 - January 11, 2024
10%
Flag icon
Between 1932 and 1972, several hundred African-American men with syphilis in Macon County, Alabama, went deliberately untreated by medical professionals, as part of a forty-year experiment by the US Public Health Service known as the Tuskegee Syphilis Study.
10%
Flag icon
The Belmont Report lays out a foundation for the ethical practice of medical experiments, so that the Tuskegee experiment—an egregious, unambiguously inappropriate breach of the health profession’s duty to its patients—might never be repeated.
11%
Flag icon
In general, it seems that people tend to over-explore—to favor the new disproportionately over the best.
12%
Flag icon
If the probabilities of a payoff on the different arms change over time—what has been termed a “restless bandit”—the problem becomes much harder.
12%
Flag icon
To live in a restless world requires a certain restlessness in oneself. So long as things continue to change, you must never fully cease exploring.
12%
Flag icon
the algorithmic techniques honed for the standard version of the multi-armed bandit problem are useful even in a restless world.
12%
Flag icon
Alison Gopnik, professor of developmental psychology at UC Berkeley and author of The Scientist in the Crib, has an explanation for why human beings have such an extended period of dependence: “it gives you a developmental way of solving the exploration/exploitation tradeoff.”
12%
Flag icon
“Childhood gives you a period in which you can just explore possibilities, and you don’t have to worry about payoffs because payoffs are being taken care of by the mamas and the papas and the grandmas and the babysitters.”
12%
Flag icon
it’s actually rational to emphasize exploration—the new rather than the best, the exciting rather than the safe, the random rather than the considered—for many of those choices, particularly earlier in life.
12%
Flag icon
I had reached a juncture in my reading life that is familiar to those who have been there: in the allotted time left to me on earth, should I read more and more new books, or should I cease with that vain consumption—vain because it is endless—and begin to reread those books that had given me the intensest pleasure in my past. —LYDIA DAVIS
12%
Flag icon
The basic pattern is clear: the size of people’s social networks (that is, the number of social relationships they engage in) almost invariably decreases over time.
12%
Flag icon
these decreases are “the result of lifelong selection processes by which people strategically and adaptively cultivate their social networks to maximize social and emotional gains and minimize social and emotional risks.”
12%
Flag icon
the shrinking of social networks with aging is due primarily to “pruning” peripheral relationships and focusing attention instead on a core of close friends and family members.
12%
Flag icon
these differences in social preference are not about age as such—they’re about where people perceive themselves to be on the interval relevant to their decision.
12%
Flag icon
Perhaps the deepest insight that comes from thinking about later life as a chance to exploit knowledge acquired over decades is this: life should get better over time. What an explorer trades off for knowledge is pleasure.
13%
Flag icon
exploration necessarily leads to being let down on most occasions.
13%
Flag icon
sorting is also key to the human experience of information.
13%
Flag icon
Sorting involves steep diseconomies of scale, violating our normal intuitions about the virtues of doing things in bulk.
13%
Flag icon
the first and most fundamental insight of sorting theory. Scale hurts.
14%
Flag icon
Computer science has developed a shorthand specifically for measuring algorithmic worst-case scenarios: it’s called “Big-O” notation.
14%
Flag icon
Big-O notation provides a way to talk about the kind of relationship that holds between the size of the problem and the program’s running time.
14%
Flag icon
Imagine you’re hosting a dinner party with n guests. The time required to clean the house for their arrival doesn’t depend on the number of guests at all. This is the rosiest class of problems there is: called “Big-O of one,” written O(1), it is also known as “constant time.”
14%
Flag icon
the time required to pass the roast around the table will be “Big-O of n,” written O(n), also known as “linear time”—with twice the guests, you’ll wait twice as long for the dish to come around.
14%
Flag icon
the existence of any linear-time factors will, in Big-O notation, swamp all constant-time factors.
14%
Flag icon
What if, as the guests arrived, each one hugged the others in greeting? Your first guest hugs you; your second guest has two hugs to give; your third guest, three. How many hugs will there be in total? This turns out to be “Big-O of n-squared,” written O(n2) and also known as “quadratic time.”
14%
Flag icon
Constant time, written O(1); linear time, written O(n); and quadratic time, written O(n2).
14%
Flag icon
There’s “exponential time,” O(2n), where each additional guest doubles your work. Even worse is “factorial time,” O(n!),
14%
Flag icon
Imagine you want to alphabetize your unsorted collection of books. A natural approach would be just to scan across the shelf looking for out-of-order pairs—Wallace followed by Pynchon, for instance—and flipping them around. Put Pynchon ahead of Wallace, then continue your scan, looping around to the beginning of the shelf each time you reach the end. When you make a complete pass without finding any out-of-order pairs on the entire shelf, then you know the job is done. This is Bubble Sort, and it lands us in quadratic time.
14%
Flag icon
There are n books out of order, and each scan through the shelf can move each one at most one position.
14%
Flag icon
So in the worst case, where the shelf is perfectly backward, at least one book will need to be moved n positions. Thus a maximum of n passes through n book...
This highlight has been truncated due to consecutive passage length restrictions.
14%
Flag icon
it means that sorting five shelves of books will take not five times as long as sorting a single shelf, but twenty-five times as long.
14%
Flag icon
pulling all the books off the shelf and putting them back in place one by one. You’d put the first book in the middle of the shelf, then take the second and compare it to the first, inserting it either to the right or to the left. Picking up the third book, you’d run through the books on the shelf from left to right until you found the right spot to tuck it in. Repeating this process, gradually all of the books would end up sorted on the shelf and you’d be done. Computer scientists call this, appropriately enough, Insertion Sort.
14%
Flag icon
Although in practice Insertion Sort does run a bit faster than Bubble Sort, again we land squarely, if you will, in quadratic time.
14%
Flag icon
What is the minimum effort required to make order?
15%
Flag icon
Sorting two cards is simple: just put the smaller one on top. And given a pair of two-card stacks, both of them sorted, you can easily collate them into an ordered stack of four. Repeating this trick a few times, you’d build bigger and bigger stacks, each one of them already sorted. Soon enough, you could collate yourself a perfectly sorted full deck—with a final climactic merge, like a riffle shuffle’s order-creating twin, producing the desired result. This approach is known today as Mergesort, one of the legendary algorithms in computer science.
15%
Flag icon
The power of Mergesort comes from the fact that it indeed ends up with a complexity between linear and quadratic time—specifically, O(n log n), known as “linearithmic” time.
15%
Flag icon
If you’re still strategizing about that bookshelf, the Mergesort solution would be to order a pizza and invite over a few friends. Divide the books evenly, and have each person sort their own stack. Then pair people up and have them merge their stacks. Repeat this process until there are just two stacks left, and merge them one last time onto the shelf.
15%
Flag icon
A Mergesort in action. Given a shelf of eight unsorted books, start by putting adjacent books into sorted pairs. Then collate the pairs into ordered sets of four, and finally collate those sets to get a fully sorted shelf.
15%
Flag icon
It’s been proven that if we want to fully sort n items via a series of head-to-head comparisons, there’s just no way to compare them any fewer than O(n log n) times. It’s a fundamental law of the universe, and there are no two ways around it.
15%
Flag icon
Because sometimes you don’t need a fully ordered set—and sometimes sorting can be done without any item-to-item comparisons at all. These two principles, taken together, allow for rough practical sorts in faster than linearithmic time. This is beautifully demonstrated by an algorithm known as Bucket Sort—
15%
Flag icon
In Bucket Sort, items are grouped together into a number of sorted categories, with no regard for finer, intracategory sorting; that can come later.
15%
Flag icon
(In computer science the term “bucket” simply refers to a chunk of unsorted data,
15%
Flag icon
if you want to group n items into m buckets, the grouping can be done in O(nm) time—that is, the time is simply proportional to the number of items times the number of buckets. And as long as the number of buckets is relatively small compared to the number of items, Big-O notation will round that to O(n), or linear time.
15%
Flag icon
The key to actually breaking the linearithmic barrier is knowing the distribution from which the items you’re sorting are drawn.
15%
Flag icon
a good strategy—ratified by human and machine librarians alike—is to Bucket Sort until you get down to small enough piles that Insertion Sort is reasonable, or to have a Mergesort pizza party.
16%
Flag icon
one of the most central tradeoffs is between sorting and searching. The basic principle is this: the effort expended on sorting materials is just a preemptive strike against the effort it’ll take to search through them later.
16%
Flag icon
Err on the side of messiness.
16%
Flag icon
Sorting something that you will never search is a complete waste; searching something you never sorted is merely inefficient.
16%
Flag icon
Computer science shows that the hazards of mess and the hazards of order are quantifiable and that their costs can be measured in the same currency: time.
16%
Flag icon
Sometimes mess is more than just the easy choice. It’s the optimal choice.