John D. Cook
johndcook.com · Personal blog · on HN since 2009
John D. Cook, a consultant in applied math and statistics, writes short posts on numerical computing, probability, and programming.
What HN saysCommenters cite his Kalman filter note as helping them understand it, and credit his Gorilla Banana post. His posts draw math discussion.
648HN people shared it
251linked it in comments
1.5Kstories submitted
26Kstory points
2 months agolast shared
2009people per year2026
Most-shared posts
- 1Opening Black Boxes15 people · 11 points · first shared 2009 · 4 comments on HN
- 2How to fit an elephant (2011)14 people · 93 points · first shared 2011 · 23 comments on HN
- 3Don’t invert that matrix (2010)13 people · 295 points · first shared 2010 · 42 comments on HN
- 4Gell-Mann amnesia and its opposite13 people · 47 points · first shared 2021 · 23 comments on HN
- 5What happens when you add a new teller? (2008)11 people · 150 points · first shared 2015 · 36 comments on HN
- 6You Wanted a Banana but Got a Gorilla Holding the Banana and the Entire Jungle11 people · 12 points · first shared 2011 · 2 comments on HN
- 7Anatomy of a Posit Number9 people · 38 points · first shared 2018 · 3 comments on HN
- 8Why programmers are not paid in proportion to their productivity8 people · 818 points · first shared 2009 · 306 comments on HN
- 9Selection bias and bombers (2008)7 people · 110 points · first shared 2010 · 18 comments on HN
- 10Dumb and gets things done7 people · 108 points · first shared 2010 · 24 comments on HN
- 11Estimating the chances of something that hasn’t happened yet6 people · 584 points · first shared 2010 · 150 comments on HN
- 12R programming for those coming from other languages6 people · 212 points · first shared 2009 · 29 comments on HN
- 13Where the Unix philosophy breaks down6 people · 88 points · first shared 2010 · 55 comments on HN
- 14Algorithms vs. Moore’s Law6 people · 39 points · first shared 2015 · 8 comments on HN
- 15OO vs. FP programming6 people · 16 points · first shared 2010 · discussion on HN
What HN people wrote when they linked it
pxc · 2025-12-26
> Why ever use Ruby when there’s a virtually identical system [...] with a bigger community.
There was a time in the history of Python when people who chose Python did so primarily because they found it beautiful or pleasant to work with. These are reasonable factors in choosing a language, and they continue to be popular reasons for choosing relatively unpopular languages today.
A related essay has made the rounds on HN before. It might be worth revisiting if this question is on your mind: https://www.johndcook.com/blog/2011/10/26/python-is-a-voluntary-langua…
uticus · 2025-10-30
...followup after looking through comments on OP, indeed someone else already had the idea to tie in OEIS sequences in the comment at https://www.johndcook.com/blog/2025/10/26/987654321/#comment-1191863
but i still wonder if there is something like OEIS for observations / analysis like this
pash · 2025-08-15
For some definition of “sufficiently introductory”, I’d recommend starting with the first chapter of John Nolan’s book Stable Distributions [0] (20 pages), which presents the class of distributions to which sums of iid random variables converge and builds up to a version of the generalized CLT.
Note that this generalization of the classical CLT relaxes the requirement of finite mean and variance but still requires that the summed random variables are iid. There are further generalizations to sums of dependent random variables. John D. Cook has a good blog post that gives a quick overview of these generalizations [1].
0. https://edspace.american.edu/jpnolan/wp-content/uploads/sites/1720/202… [PDF]
1. https://www.johndcook.com/blog/central_limit_theorems/
turbocon · 2024-06-21
Id just like to point out the source of the Gorilla Banana problem is Joe Armstrong. He really had an amazing way of explain complex problems in a simple way.
https://www.johndcook.com/blog/2011/07/19/you-wanted-banana/
havercosine · 2023-08-03
This is a great post. Another aha! moment I had in understanding Kalman Filter came from a short note by John D. Cook (link: https://www.johndcook.com/blog/applied-kalman-filtering/) . A traditional calculus/differential equations based modelling of systems takes a view that there is no uncertainty in the data and everything is captured by system model. OTOH, data driven estimator will say that "it is all in the data", completely ignoring the model of the physical process that is generating the data. Beauty of Kalman filters is that it combines these two approaches.
latexr · 2023-05-20
> Also disappointing that they didn't follow up the incorrect responses with corrections. Like if you told gpt that "sorry, your answer is wrong because the stock market is closed on saturday", it would come up wiht a new answer that takes that into account.
If you have to keep correcting the tool yourself, you won’t arrive at the truth but at the limits of your own knowledge. You’ll have no basis to know which answer is the one you can finally trust.
That mode of operation reminds me of the Gell-Mann amnesia effect.
https://www.johndcook.com/blog/2021/01/18/gell-mann-amnesia/
cannam · 2023-02-09
The same author wrote another very useful post in 2010 that also involved mediants:
https://www.johndcook.com/blog/2010/10/20/best-rational-approximation/
abhgh · 2022-06-28
Highly recommend his blog [1] - where he often writes bite-sized math-y articles. I have personally benefited from it; I was looking for ways to sample quickly from a mixture of Beta distributions when I stumbled upon his post on the Kumaraswamy distribution [2], which takes on Beta-like shapes but has a closed form expression for the cumulative distribution function (CDF). The latter property makes generating samples from it convenient and fast.
[1] https://www.johndcook.com/blog/
[2] https://www.johndcook.com/blog/2009/11/24/kumaraswamy-distribution/
rotifer · 2022-03-08
To the section "Popular Math Books" I would add almost anything by Julian Havil. John D. Cook referred to him as a writer of "serious recreational mathematics" [1]. I would probably put his "Nonplussed!" and "Impossible?" books in the "Level: Easy" group, with the others at least in "Level: Medium". "Gamma" is one of my favorite serious recreational math books.
If you like getting into the nitty-gritty of problem solving then check out the books of Paul Nahin. They vary between "Level: Medium" and "Level: Difficult", with many of them reveling in the solution of equations, and integrals in particular. Although he recognizes the need for proofs, he makes a point of avoiding them in his books.
[1] https://www.johndcook.com/blog/2019/09/29/a-sort-of-mathematical-quine…
throwaway894345 · 2021-12-10
Not everyone is a Kingdom of Nouns purist. Even most OOP proponents that I've spoken with reject Kingdom of Nouns because it's pretty indefensible (in the worst case it leads to banana-gorilla-jungle problems[0] and in the best case it imposes arbitrary and unnatural restrictions on program design). Note also that "modern Java" and "modern C#" and "modern C++" and "modern Python" virtually all reject these kinds of designs and end up looking a lot more like Go with respect to their use of structs/classes.
[0]: https://www.johndcook.com/blog/2011/07/19/you-wanted-banana/
_nalply · 2021-09-01
I found about posits.
https://www.johndcook.com/blog/2018/04/11/anatomy-of-a-posit-number/
Perhaps CFP8 are parameterized 8-bit posits where the parameter is the value es. The larger es is, the greater the dynamic range is at the expense of precision. Two examples:
posit<8, 0> (es = 0) has as largest positive number 64 and the smallest positive number 1/64.
posit<8, 1> (es = 1) has as largest positive number 4012 and the smallest positive number 1/4012.
The formula for the largest positive number for 8-bit posits is:
2 ^ 2 ^ es ^ 6.
posits don't have NaNs and only one infinity (±∞), so they can use more of the 8 bit values for numbers than floating point numbers.
I wonder: is CFP8 = posit<8, es>?
jeroenhd · 2021-07-29
What's the output of these special unifont characters in screen readers? Does it state every character as "bold A, bold B, bold C"?
Edit: actually, the author addresses in a follow-up post [0] why it shouldn't matter. I'm no expert on the area, though.
[0]: https://www.johndcook.com/blog/2021/07/19/removing-unicode-formatting/
thaumasiotes · 2021-06-18
You want to consider, based on a distribution of potential fly populations, what the odds are that sampling two of them will fail to capture two specific ones. For example, you can state with certainty that the population is above 3.
Closely related (though not quite the identical problem): https://www.johndcook.com/blog/2010/03/30/statistical-rule-of-three/
Applying that directly, we would estimate that the odds of a fly in your house being marked are less than 150%, which tells us that you should be taking larger samples.
(With only two marked flies, this estimate will always be less informative than the fact that you sampled n flies -- it will tell you that the population is probably greater than 2/3 of n, while the sampling procedure tells you that the population is necessarily at least n+2. But as you mark more flies, the estimate will be more informative.)
anthony_romeo · 2021-05-20
John D. Cook (who has one of my favorite blogs on the web) recently had a few helpful posts about divisibility rules:
- Divisibility by 7, 11, 13: https://www.johndcook.com/blog/2020/11/10/test-for-divisibility-by-13/
- Divisibility by any prime using determinants: https://www.johndcook.com/blog/2021/02/17/divisibility-by-any-prime/
RcouF1uZ4gsC · 2021-03-25
Unfortunately, the article did not have what I think is the best Joe Armstrong quote on OOP.
Here it is as quoted in:
https://www.johndcook.com/blog/2011/07/19/you-wanted-banana/
>I think the lack of reusability comes in object-oriented languages, not functional languages. Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.
h2odragon · 2020-12-09
I'd expect those walls to disperse and muffle sound as opposed to a flat wall, which would echo and reinforce parts and make a space noisier. The curves should make for more of a white noise effect.
the linked post https://www.johndcook.com/blog/2019/11/19/crinkle-crankle-calculus/ is worth the click too.
netmare · 2020-09-28
There's always 355/113. It's roughly approximate to 6.6 digits† and strangely it's been easier for me to remember than 22/7.
† https://www.johndcook.com/blog/2018/05/22/best-approximations-for-pi/
inopinatus · 2020-09-07
Ahem. The “gorilla holding the banana” metaphor is from Joe Armstrong — creator of that “ugly-ass language” Erlang; what’s more, it is about emergent reusability in comparative programming paradigms, not about being unwilling to follow a learning curve.
https://www.johndcook.com/blog/2011/07/19/you-wanted-banana/
mrkeen · 2020-02-03
What software are you using that once or twice a year doesn't count as "rarely"?
My Viaplay app stops streaming and tells me I'm not connected to the internet several times a day (when I'm obviously still connected to the internet.)
Several times a week my phone's Netflix state doesn't match my TV's state, so I'm either not presented with the controls or when I press them they do nothing.
Cosmic bit-flips are rare enough to be newsworthy.
https://www.johndcook.com/blog/2019/05/20/cosmic-rays-flipping-bits/
If the faults were with the hardware, I'd expect the errors to be spread around the software that I use. But Firefox and Gmail always work for me (even if the JavaScript I'm served makes the machine unresponsive), whereas Netflix, Viaplay and HBO constantly misbehave.
pixelpoet · 2019-11-09
How did they use an elephant as cover image without mentioning von Neumann's famous and relevant quote: "With four parameters I can fit an elephant, and with five I can make him wiggle his trunk."
A great article on it: https://www.johndcook.com/blog/2011/06/21/how-to-fit-an-elephant/
taeric · 2018-07-12
Honestly, most of the introduction I've seen has been bottom up or from new hires. I think there is a major point in having happy development environments. Happiness with tools is a very important point that is hard to quantify. https://www.johndcook.com/blog/2011/07/31/enjoyment-of-ones-tools/ has a fun exploration of two great quotes on this vein.
That said, if you can, I'd be ridiculously interested in a retrospective when you have a chance on your transition. Good luck with it!
effie · 2017-11-26
Is it really necessary to invert those matrices? Often that is possible, but not the best way to find the solution of the problem:
https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/
R_haterade · 2017-09-27
Excellent John D. Cook piece on the same subject: https://www.johndcook.com/blog/2010/01/19/dont-invert-that-matrix/
Uzomidy · 2017-09-10
This has nothing to do with cryptographic security or predictability.
This is about whether the output of the PRNG passes statistical tests for randomness. In a previous blog post by John D. Cook we saw that it failed the PractRand statistical test suite [1], and now we see that it also fails the older TestU01 suite, too.
When Xorshift128+ and Xoroshiro128+ were launched, they were claimed to be statistically excellent. Those claims have been shown to be false.
[1] https://www.johndcook.com/blog/2017/08/14/testing-rngs-with-practrand/
throwaway_374 · 2017-04-26
Tangential but it does irk me when these online streaming summary statistics algorithms come up in interviews. Most recently I had Welford's for online estimation of variance/std optimised for numerical stability. Great, fascinating stuff, there's FP representation issues but really is this necessary to quiz... mostly just the interviewer trying to show off how clever they are.
https://www.johndcook.com/blog/standard_deviation/
dmfdmf · 2016-12-31
Here is an interesting blog post by John D. Cook on how too much news creates an "Inverted Sense of Risk"
http://www.johndcook.com/blog/2014/09/05/inverted-sense-of-risk/
While I highly recommend not being too connected to the concretes and noise of the day, i.e. news, I think sticking your head in the sand is not such a great idea either. Nobody planned on or set out to design and build tanks, cars, plane, guns, bombs, ciphers or databases for the Nazis but people actually did.
baldfat · 2016-11-03
Unix Philosophy makes thing overly complex and Unix doesn't follow Unix Philosophy. All these little programs have over lapping features.
http://www.johndcook.com/blog/2010/06/30/where-the-unix-philosophy-bre…
man page for ls and see if they built a ton onto the little program and not just write new programs.
tom_b · 2016-10-14
I agree with the above recommendation.
I have read John Cook's blog for some time and think he might be a good fit as a consultant for bringing you up to speed and reviewing your current teams' work.
http://www.johndcook.com/blog/
I suspect it would be worth your time to get a consultant like him to come in for a week, review all the work going on in your org, and maybe lay out a learning plan or crash course in developing a safety net for you.
bbotond · 2016-07-07
The first comment, written by none other than Peter Norvig, is also worth reading.
EDIT: link - http://www.johndcook.com/blog/2016/07/06/literate-programming-presenti…
wolfram74 · 2016-03-10
While we're reaching the physical limits of classical chip design, do we have any ideas what the limits are on the algorithm side of things? As much speed up has come from software as hardware according to a few reports.
http://www.johndcook.com/blog/2015/12/08/algorithms-vs-moores-law/