Feed john-d-cook John D. Cook

Favorite IconJohn D. Cook

Link https://www.johndcook.com/blog
Feed http://feeds.feedburner.com/TheEndeavour?format=xml
Updated 2025-09-12 05:16
How to digitize a graph
Suppose you have a graph of a function, but you don’t have an equation for it or the data that produced it. How can you reconstruction the function? There are a lot of software packages to digitize images. For example, Web Plot Digitizer is one you can use online. Once you have digitized the graph […]
Linear or not, random or not, at different levels
Linear vs nonlinear I’ve run across a lot of ambiguity lately regarding systems described as “nonlinear.” Systems typically have several layers, and are linear at one level and nonlinear at another, and authors are not always clear about which level they’re talking about. For example, I recently ran across something called a “nonlinear trapezoid filter.” My first instinct […]
The intersection of genomes is empty
From this story in Quanta Magazine: In fact, there’s no single set of genes that all living things need in order to exist. When scientists first began searching for such a thing 20 years ago, they hoped that simply comparing the genome sequences from a bunch of different species would reveal an essential core shared […]
Magic hexagon
The following figure is a magic hexagon: the numbers in any straight path through the figure add to 38, even though paths may have length three, four, or five. I found this in Before Sudoku. The authors attribute it to Madachy’s Mathematical Recreations. This is essentially the only magic hexagon filled with consecutive integers starting with one. The […]
Personal growth and discrete harmonic functions
“You are the average of the five people you spend the most time with.” A Google search says this quote is by Jim Rohn. I think other people have said similar things. I’ve heard it quoted many times. The implication is usually that you can improve your life by hanging around better people. Here are three things […]
Technical memento mori
The Latin phrase memento mori means “remember that you must die.” It has been adopted into English to refer to an object that serves as a reminder of death, especially a skull. This is a common theme in art, such as Albrecht Dürer’s engraving St. Jerome in His Study. I keep a copy of the book Inside […]
Well, F = ma.
Three or four very short stories on the difficulty of learning to use simple things. Depends whether you count the last section as a story. * * * When I was taking freshman physics and we were stuck on a problem, the professor would say “Well, F = ma.” True, but absolutely useless. Yes, we know that F = […]
Magic square rows and columns as numbers
Take any 3 by 3 magic square. For example, here’s the ancient Lo Shu square: If you read the rows as numbers and sum their squares, you get the same thing whether you read left to right or right to left. In this case 4922 + 3572 + 8162 = 2942 + 7532 + 6182. […]
Alphamagic squares in French
In earlier blog posts I give examples of alphamagic squares in English and in Spanish. This post looks at French. The Wikipedia article on alphamagic squares, quoting The Universal Book of Mathematics, says French allows just one 3 × 3 alphamagic square involving numbers up to 200, but a further 255 squares if the size of the […]
Alphamagic square in Spanish
In a previous post I gave an example of an alphamagic square in English. This is a magic square such that if you replace each number with the letter count when spelling out the word, you get another magic square. I wondered whether I could find an alphamagic square in Spanish, so I wrote a […]
Roughness of amplitude modulated tones
A recent post pointed out that two pure tones that are fairly close in pitch create a rough sound. The roughness increases with the frequency difference, up to a point, then decreases. This post will look at a roughness in a different setting, amplitude modulation. Several psychoacoustics researchers have suggested that perceived roughness increases as […]
An alphamagic square
British engineer Lee Sallows came up with the following unusual magic square. If you spell out the English name of each number then replace the contents of each cell with the number of letters inside you get another magic square! Update: Here are a couple alphamagic squares in Spanish and more in French.
Acoustic roughness
When two pure tones are nearly in tune, you hear beats. The perceived pitch is the average of the two pitches, and you hear it fluctuate as many times per second as the difference in frequencies. For example, an A 438 and an A 442 together sound like an A 440 that beats four times […]
Bayesian adaptive clinical trials: promise and pitfalls
This afternoon I’m giving a talk at the Houston INFORMS chapter entitled “Bayesian adaptive clinical trials: promise and pitfalls.” When I started working in adaptive clinical trials, I was very excited about the potential of such methods. The clinical trial methods most commonly used are very crude, and there’s plenty of room for improvement. Over […]
Paying for doughnuts with a phone
At a doughnut shop today, I noticed the people at the head of each line were using their phones, either to pay for an order or to use a coupon. I thought how ridiculous it would sound if I were to go back twenty or thirty years and tell my mother about this. Me: Some day […]
Cornu’s spiral
Cornu’s spiral is the curve parameterized by where C and S are the Fresnel functions, sometimes called the Fresnel cosine integral and Fresnel sine integral. Here’s a plot of the spiral. Both Fresnel functions approach ½ as t → ∞ and so the curve slowly spirals toward (½, ½) in the first quadrant. And by symmetry, […]
Categorical products
Introduction There’s an odd sort of partisan spirit to discussions of category theory. They often have the flavor of “Category theory is great!” or “Category theory is a horrible waste of time!” You don’t see this sort of partisanship around, say, probability. Probability theory is what it is, and if you need it, you use […]
New Twitter logos
I’ve updated the icons of all my daily tip Twitter accounts. My goal was to simplify some the icons and make them all more consistent. Here’s a page giving links and short descriptions for each account.
Science fiction recommendations
I like science fiction as a genre, but I dislike most science fiction books I’ve tried. I start with books that come highly recommended and give up on most of them. But here are a few I’ve read and enjoyed.
Beats: amplitude modulation in radios and musical instruments
What do tuning a guitar and tuning a radio have in common? Both are examples of beats or amplitude modulation. Examples In an earlier post I wrote about how beats come up in vibrating systems, such as a mass and spring combination or an electric circuit. Here I look at examples from music and radio. Music When two […]
Creating police siren sounds with frequency modulation
Yesterday I was looking into calculating fluctuation strength and playing around with some examples. Along the way I discovered how to create files that sound like police sirens. These are sounds with high fluctuation strength. The Python code below starts with a carrier wave at fc = 1500 Hz. Not surprisingly, this frequency is near where […]
Frequentist properties of Bayesian methods
Bayesian methods for designing clinical trials have become more common, and yet these Bayesian designs are almost always evaluated by frequentist criteria. For example, a trial may be designed to stop early 95% of the time under some bad scenario and stop no more than 20% of the time under some good scenario. These criteria […]
If it were easy …
“If it were easy, someone would have done it.” Maybe not. Maybe the thing is indeed easy, and has been done before. Then someone was the first to do it. The warning that it had been done before didn’t apply to this person, even though it would apply to the subsequent people with the same […]
The magic / boilerplate trade-off
Phil Webb had an insightful tweet the other day. What would you like to complain about? [ ] Too much magic [ ] Too much boilerplate — Phil Webb (@phillip_webb) March 5, 2016 Programming environments oscillate between boilerplate and magic. APIs tend to start out with all the wires exposed. Programming is tedious, but nothing […]
Correlation of two sine waves
What is the correlation of two sine waves that differ in phase? The result itself is interesting, and the calculation along the way shows tricks to avoid calculating integrals. The correlation of two periodic signals, f and g, is where the integral is over a period of the two functions. For functions known at discrete points […]
Continuum between anecdote and data
The difference between anecdotal evidence and data is overstated. People often have in mind this dividing line where observations on one side are worthless and observations on the other side are trustworthy. But there’s no such dividing line. Observations are data, but some observations are more valuable than others, and there’s a continuum of value. I believe […]
Frequently rediscovered technologies
Greenspun’s tenth rule of programming says Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. Here I’m going to take seriously a rule that was only not entirely serious. It’s saying three things about Lisp. It’s a frequently rediscovered technology. There’s something inevitable about it. […]
Coffee after Obama
This morning I had coffee and a generous slice of squash bread at Top Pot Doughnuts in Seattle. When I went to pick up my coffee I saw a large photo of President Obama ordering coffee at the same place. This is the second time I’ve been at a shop that proudly remembered our president […]
Octave holes on a saxophone
I’ve played saxophone since I was in high school, and I thought I knew how saxophones work, but I learned something new this evening. I was listening to a podcast [1] on musical acoustics and much of it was old hat. Then the host said that a saxophone has two octave holes. Really?! I only thought […]
Searching files on Windows
Searching files on Windows is a pain. The built-in search features don’t find everything. There may be ways to make them work, but I haven’t persisted long enough to make them work. On Linux, the combination of find, xargs, and grep works well, and sometimes it works on Windows using the GOW or GnuWin port of […]
Energy in frequency modulated signals
In an earlier post we proved that if you modulate a cosine carrier by a sine signal you get a signal whose sideband amplitudes are given by Bessel functions. Specifically: When β = 0, we have the unmodulated carrier, cos(2π fct), on both sides. When β is positive but small, J0(β) is near 1, and so the frequency […]
Quantifying Loudness
How do you quantify how loud a sound is? Sounds like a simple question, but it’s not. What is loudness? It’s not hard to measure the physical intensity of a sound, but loudness is the perceived intensity of a sound. It is not a physical phenomena but a psychological phenomena. Loudness is subjective, but not entirely […]
Rigor and Vigor in Mathematics
I just started reading Frequency Analysis, Modulation and Noise by Stanford Goldman. The writing is strikingly elegant and clear. Here is a paragraph from the introduction. Rigorous mathematics has a rightful place of honor in human thought. However, it has wisely been said that vigor is more important than rigor in the use of mathematics by the average […]
Graphs and square roots modulo a prime
Imagine a clock with a prime number of hours. So instead of being divided into 12 hours, it might be divided into 11 or 13, for example. You can add numbers on this clock the way you’d add numbers on an ordinary clock: add the two numbers as ordinary integers and take the remainder by p, […]
The empty middle: why no one is average
In 1945, a Cleveland newspaper held a contest to find the woman whose measurements were closest to average. This average was based on a study of 15,000 women by Dr. Robert Dickinson and embodied in a statue called Norma by Abram Belskie. Out of 3,864 contestants, no one was average on all nine factors, and fewer than 40 […]
Analyzing an FM signal
Frequency modulation combines a signal with a carrier wave by changing (modulating) the carrier wave’s frequency. Starting with a cosine carrier wave with frequency fc Hz and adding a signal with amplitude β and frequency fm Hz results in the combination The factor β is known as the modulation index. We’d like to understand this signal […]
Formulating applied math problems
Somewhere in school I got the backward idea that solving math problems is hard but that formulating them is easy. I don’t know if anybody ever said that to me. Maybe it was just implied by years of solving problems someone else had formulated. A related wrong idea that I also picked up was that […]
Curious numbers
A an n-digit number is said to be curious if the last n digits of its square are the same as the original number. For example, 252 = 625 and 762 = 5776. (Curious numbers are also known as automorphic numbers.) There are bigger curious numbers, such as 212890625 and 787109376: 2128906252 = 45322418212890625 and 7871093762 = 619541169787109376. And […]
Types of nonlinearity in PDEs
My advisor in grad school used to say “Nonlinear” is not a hypothesis but the lack of a hypothesis. To say something positive about nonlinear equations, you have to replace linearity with some specific property. You want to partially remove the restriction of linearity without letting just anything in. In partial differential equations, one pattern […]
Bayesian and nonlinear
Someone said years ago that you’ll know Bayesian statistics has become mainstream when people no longer put “Bayesian” in the titles of their papers. That day has come. While the Bayesian approach is still the preferred approach of a minority of statisticians, it’s no longer a novelty. If you want people to find your paper interesting, the substance […]
Improving on Chebyshev’s inequality
Chebyshev’s inequality says that the probability of a random variable being more than k standard deviations away from its mean is less than 1/k2. In symbols, This inequality is very general, but also very weak. It assumes very little about the random variable X but it also gives a loose bound. If we assume slightly more, […]
Trends and Opportunities in Data Analysis
Andy Warhol said “In the future, everyone will be world-famous for 15 minutes.” Here’s my 15 seconds of fame, a soundbite from the IBM Insight conference last year. My comments start at 1:30. In a nutshell, I predict that data analytics will work its way down from large companies to small companies.
Maximum principles and bounds for initial value problems
The previous post looked at using maximum principles to bound the solution to a boundary value problem. This is a similar post, focusing on an initial value problem. As before we start with the differential operator L[u] = u” + g(x)u’ + h(x) where g and h are bounded and h is non-positive. We are interested in solutions to the equation L[u] = f, but […]
Maximum principle and approximating boundary value problems
Solutions to differential equations often satisfy some sort of maximum principle, which can in turn be used to construct upper and lower bounds on solutions. We illustrate this in one dimension, using a boundary value problem for an ordinary differential equation (ODE). Maximum principles If the second derivative of a function is positive over an open […]
Musical pitch notation
How can you convert the frequency of a sound to musical notation? I wrote in an earlier post how to calculate how many half steps a frequency is above or below middle C, but it would be useful go further have code to output musical pitch notation. In scientific pitch notation, the C near the threshold of hearing, […]
Fourier transform of a function on a graph
What is a Fourier transform at its core? An expansion of function in terms of eigenfunctions of the Laplacian. For a function on the real line, the Laplacian is simply the second derivative. The functions mapped to multiples of themselves by taking second derivatives are sines and cosines of various frequencies. A Fourier series is a change […]
Connection between hypergeometric distribution and series
What’s the connection between the hypergeometric distributions, hypergeometric functions, and hypergeometric series? The hypergeometric distribution is a probability distribution with parameters N, M, and n. Suppose you have an urn containing N balls, M red and the rest, N – M blue and you select n balls at a time. The hypergeometric distribution gives the probability of selecting k red balls. The probability generating function […]
Structure in jazz and math
Last night I went to a concert by the Branford Marsalis Quartet. One of the things that impressed me about the quartet was how creative they are while also being squarely within a tradition. People who are not familiar with jazz may not realize how structured it is and how much it respects tradition. The spontaneous and […]
Consulting for consultants
They say that doctors make terrible patients, but in my experience consultants make great consulting clients. The best are confident in their own specialization and respect you in yours. They get going quickly and pay quickly. (I’ve only worked for consultants who have small companies. I imagine large consulting companies are as slow as other companies the same […]
Dilogarithm, polylogarithm, and related functions
The functions dilogarithm, trilogarithm, and more generally polylogarithm are meant to be generalizations of the logarithm. I first came across the dilogarithm in college when I was evaluating some integral with Mathematica, and they’ve paid a visit occasionally ever since. Unfortunately polylogarithms are defined in several slightly different and incompatible ways. I’ll start by following An Atlas […]
...525354555657585960