书评：《算法之美（ Algorithms to Live By ）》
算法
![](/data/attachment/album/201810/01/112752vuko5cufxojjmo4x.png)


又一次为了工作图书俱乐部而读书。除了其它我亲自推荐的书，这是我至今最喜爱的书。


作为计算机科学基础之一的研究领域是算法：我们如何高效地用计算机程序解决问题？这基本上属于数学领域，但是这很少关于理想的或理论上的解决方案，而是更在于最高效地利用有限的资源获得一个充分（如果不能完美）的答案。其中许多问题要么是日常的生活问题，要么与人们密切相关。毕竟，计算机科学的目的是为了用计算机解决实际问题。《<ruby> 算法之美 <rt>  Algorithms to Live By </rt></ruby>》提出的问题是：“我们可以反过来吗”——我们可以通过学习计算机科学解决问题的方式来帮助我们做出日常决定吗？


本书的十一个章节有很多有趣的内容，但也有一个有趣的主题：人类早已擅长这一点。很多章节以一个算法研究和对问题的数学分析作为开始，接着深入到探讨如何利用这些结果做出更好的决策，然后讨论关于人类真正会做出的决定的研究，之后，考虑到典型生活情境的限制，会发现人类早就在应用我们提出的最佳算法的特殊版本了。这往往会破坏本书的既定目标，值得庆幸的是，它决不会破坏对一般问题的有趣讨论，即计算机科学如何解决它们，以及我们对这些问题的数学和技术形态的了解。我认为这本书的自助效用比作者打算的少一些，但有很多可供思考的东西。


（也就是说，值得考虑这种一致性是否太少了，因为人类已经擅长这方面了，更因为我们的算法是根据人类直觉设计的。可能我们的最佳算法只是反映了人类的思想。在某些情况下，我们发现我们的方案和数学上的典范不一样，但是在另一些情况下，它们仍然是我们当下最好的猜想。)


这是那种章节列表是书评里重要部分的书。这里讨论的算法领域有最优停止、探索和利用决策（什么时候带着你发现的最好东西走，以及什么时候寻觅更好的东西），以及排序、缓存、调度、贝叶斯定理（一般还有预测）、创建模型时的过拟合、放松（解决容易的问题而不是你的实际问题）、随机算法、一系列网络算法，最后还有游戏理论。其中每一项都有有用的见解和发人深省的讨论——这些有时显得十分理论化的概念令人吃惊地很好地映射到了日常生活。这本书以一段关于“可计算的善意”的讨论结束：鼓励减少你自己和你交往的人所需的计算和复杂性惩罚。


如果你有计算机科学背景（就像我一样），其中许多都是熟悉的概念，而且你因为被普及了很多新东西或许会有疑惑。然而，请给这本书一个机会，类比法没你担忧的那么令人紧张。作者既小心又聪明地应用了这些原则。这本书令人惊喜地通过了一个重要的合理性检查：涉及到我知道或反复思考过的主题的章节很少有或没有明显的错误，而且能讲出有用和重要的事情。比如，调度的那一章节毫不令人吃惊地和时间管理有关，通过直接跳到时间管理问题的核心而胜过了半数的时间管理类书籍：如果你要做一个清单上的所有事情，你做这些事情的顺序很少要紧，所以最难的调度问题是决定不做哪些事情而不是做这些事情的顺序。


作者在贝叶斯定理这一章节中的观点完全赢得了我的心。本章的许多内容都是关于贝叶斯先验的，以及一个人对过去事件的了解为什么对分析未来的概率很重要。作者接着讨论了著名的棉花糖实验。即给了儿童一个棉花糖以后，儿童被研究者告知如果他们能够克制自己不吃这个棉花糖，等到研究者回来时，会给他们两个棉花糖。克制自己不吃棉花糖（在心理学文献中叫作“延迟满足”）被发现与未来几年更好的生活有关。这个实验多年来一直被引用和滥用于各种各样的宣传，关于选择未来的收益放弃即时的快乐从而拥有成功的生活，以及生活中的失败是因为无法延迟满足。更多的邪恶分析（当然）将这种能力与种族联系在一起，带有可想而知的种族主义结论。


我对棉花糖实验有点兴趣。这是一个百分百让我愤怒咆哮的话题。


《算法之美》是我读过的唯一提到了棉花糖实验并应用了我认为更有说服力的分析的书。这不是一个关于儿童天赋的实验，这是一个关于他们的贝叶斯先验的实验。什么时候立即吃棉花糖而不是等待奖励是完全合理的？当他们过去的经历告诉他们成年人不可靠，不可信任，会在不可预测的时间内消失并且撒谎的时候。而且，更好的是，作者用我之前没有听说过的后续研究和观察支持了这一分析，观察到的内容是，一些孩子会等待一段时间然后“放弃”。如果他们下意识地使用具有较差先验的贝叶斯模型，这就完全合情合理。


这是一本很好的书。它可能在某些地方的尝试有点太勉强（数学上最优停止对于日常生活的适用性比我认为作者想要表现的更加偶然和牵强附会），如果你学过算法，其中一些内容会感到熟悉，但是它的行文思路清晰，简洁，而且编辑得非常好。这本书没有哪一部分对不起它所受到的欢迎，书中的讨论贯穿始终。如果你发现自己“已经知道了这一切”，你可能还会在接下来几页中遇到一个新的概念或一个简洁的解释。有时作者会做一些我从没想到但是回想起来正确的联系，比如将网络协议中的指数退避和司法系统中的选择惩罚联系起来。还有意识到我们的现代通信世界并不是一直联系的，它是不断缓冲的，我们中的许多人正深受缓冲膨胀这一独特现象的苦恼。


我认为你并不必须是计算机科学专业或者精通数学才能读这本书。如果你想深入，每章的结尾都有许多数学上的细节，但是正文总是易读而清晰，至少就我所知是这样（作为一个以计算机科学为专业并学到了很多数学知识的人，你至少可以有保留地相信我）。即使你已经钻研了多年的算法，这本书仍然可以提供很多东西。


这本书我读得越多越喜欢。如果你喜欢阅读这种对生活的分析，我当然是赞成的。


Rating: 9 out of 10


Reviewed: 2017-10-22




---


via: [https://www.eyrie.org/~eagle/reviews/books/1-62779-037-3.html](https://www.eyrie.org/%7Eeagle/reviews/books/1-62779-037-3.html)


作者：[Brian Christian;Tom Griffiths](https://www.eyrie.org) 译者：[GraveAccent](https://github.com/GraveAccent) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
<
|


Publisher: | Henry Holt and Company |

Copyright: | April 2016 |

ISBN: | 1-62779-037-3 |

Format: | Kindle |

Pages: | 255 |


This is an ebook, so metadata may be inaccurate or
missing. See [notes on ebooks](../notes.html#kindle) for more
information.

Another read for the work book club. This was my favorite to date, apart from the books I recommended myself.

One of the foundations of computer science as a field of study is research into algorithms: how do we solve problems efficiently using computer programs? This is a largely mathematical field, but it's often less about ideal or theoretical solutions and more about making the most efficient use of limited resources and arriving at an adequate, if not perfect, answer. Many of these problems are either day-to-day human problems or are closely related to them; after all, the purpose of computer science is to solve practical problems with computers. The question asked by Algorithms to Live By is "can we reverse this?": can we learn lessons from computer science's approach to problems that would help us make day-to-day decisions?

There's a lot of interesting material in the eleven chapters of this book, but there's also an amusing theme: humans are already very good at this. Many chapters start with an examination of algorithms and mathematical analysis of problems, dive into a discussion of how we can use those results to make better decisions, then talk about studies of the decisions humans actually make... and discover that humans are already applying ad hoc versions of the best algorithms we've come up with, given the constraints of typical life situations. It tends to undermine the stated goal of the book. Thankfully, it in no way undermines interesting discussion of general classes of problems, how computer science has tackled them, and what we've learned about the mathematical and technical shapes of those problems. There's a bit less self-help utility here than I think the authors had intended, but lots of food for thought.

(That said, it's worth considering whether this congruence is less because humans are already good at this and more because our algorithms are designed from human intuition. Maybe our best algorithms just reflect human thinking. In some cases we've checked our solutions against mathematical ideals, but in other cases they're still just our best guesses to date.)

This is the sort of a book where a chapter listing is an important part of the review. The areas of algorithms discussed here are optimal stopping, explore/exploit decisions (when to go with the best thing you've found and when to look for something better), sorting, caching, scheduling, Bayes's rule (and prediction in general), overfitting when building models, relaxation (solving an easier problem than your actual problem), randomized algorithms, a collection of networking algorithms, and finally game theory. Each of these has useful insights and thought-provoking discussion of how these sometimes-theoretical concepts map surprisingly well onto daily problems. The book concludes with a discussion of "computational kindness": an encouragement to reduce the required computation and complexity penalty for both yourself and the people you interact with.

If you have a computer science background (as I do), many of these will be
familiar concepts, and you might be dubious that a popularization would
tell you much that's new. Give this book a shot, though; the analogies
are less stretched than you might fear, and the authors are both careful
and smart about how they apply these principles. This book passes with
flying colors a key sanity check: the chapters on topics that I know well
or have thought about a lot make few or no obvious errors and say useful
and important things. For example, the scheduling chapter, which
unsurprisingly is about time management, surpasses more than half of the
time management literature by jumping straight to the heart of most time
management problems: if you're going to do everything on a list, it rarely
matters the order in which you do it, so the hardest scheduling problems
are about deciding what *not* to do rather than deciding order.

The point in the book where the authors won my heart completely was in the chapter on Bayes's rule. Much of the chapter is about Bayesian priors, and how one's knowledge of past events is a vital part of analysis of future probabilities. The authors then discuss the (in)famous marshmallow experiment, in which children are given one marshmallow and told that if they refrain from eating it until the researcher returns, they'll get two marshmallows. Refraining from eating the marshmallow (delayed gratification, in the psychological literature) was found to be associated with better life outcomes years down the road. This experiment has been used and abused for years for all sorts of propaganda about how trading immediate pleasure for future gains leads to a successful life, and how failure in life is because of inability to delay gratification. More evil analyses have (of course) tied that capability to ethnicity, with predictably racist results.

I have [kind of a thing](1-59184-679-X.html) about the marshmallow
experiment. It's a topic that reliably sends me off into angry rants.

Algorithms to Live By is the *only book* I have ever read to
mention the marshmallow experiment and then apply the analysis that I find
far more convincing. This is not a test of innate capability in the
children; it's a test of their Bayesian priors. When does it make perfect
sense to eat the marshmallow immediately instead of waiting for a reward?
When their past experience tells them that adults are unreliable, can't be
trusted, disappear for unpredictable lengths of time, and lie. And, even
better, the authors supported this analysis with both a follow-up study I
hadn't heard of before and with the observation that some children would
wait for some time and then "give in." This makes perfect sense if they
were subconsciously using a Bayesian model with poor priors.

This is a great book. It may try a bit too hard in places (applicability
of the math of optimal stopping to everyday life is more contingent and
strained than I think the authors want to admit), and some of this will be
familiar if you've studied algorithms. But the writing is clear,
succinct, and very well-edited. No part of the book outlives its welcome;
the discussion moves right along. If you find yourself going "I know all
this already," you'll still probably encounter a new concept or neat
explanation in a few more pages. And sometimes the authors make
connections that never would have occurred to me but feel right in
retrospect, such as relating exponential backoff in networking protocols
to choosing punishments in the criminal justice system. Or the
realization that our modern communication world is not constantly
connected, it's constantly *buffered*, and many of us are suffering
from the characteristic signs of buffer bloat.

I don't think you have to be a CS major, or know much about math, to read this book. There is a lot of mathematical details in the end notes if you want to dive in, but the main text is almost always readable and clear, at least so far as I could tell (as someone who was a CS major and has taken a lot of math, so a grain of salt may be indicated). And it still has a lot to offer even if you've studied algorithms for years.

The more I read of this book, the more I liked it. Definitely recommended if you like reading this sort of analysis of life.

Reviewed: 2017-10-22

<
|