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 2024-11-23 10:32
Demystifying artificial intelligence
Computers do what we tell them to do. Period. Any talk of computers doing things they weren’t programmed to do is only a way of speaking. It’s a convenient shorthand when used properly, misleading mysticism when used improperly. When you write a program print(24*7) you could say that the computer isn’t programmed to print the number […]
Optimistic about humans in aggregate
Russ Roberts from his most recent podcast: I’m a very optimistic person, and I have a lot of faith in the human enterprise writ large—not so much in any one human. I have very little faith in any one human, which is why I’m suspicious of experts and power that is centralized.
Converting between Hz, Barks, and music notation
I’ve written before about how to convert between frequency and pitch and scientific pitch notation. I’ve also written about the Bark scale. Here’s a little online calculator to convert between Hz, Bark, and music notation. You can enter one of the three and it will compute the other two.
Spectral flatness
White noise has a flat power spectrum. So a reasonable way to measure how close a sound is to being pure noise is to measure how flat its spectrum is. Spectral flatness is defined as the ratio of the geometric mean to the arithmetic mean of a power spectrum. The arithmetic mean of a sequence […]
Family tree numbering
When you draw a tree of your ancestors, things quickly get out of hand. There are twice as many nodes each time you go back a generation, and so the size of paper you need grows exponentially. Things also get messy because typically you know much more about some lines than others. If you know […]
The acoustics of kettledrums
Kettledrums (a.k.a. tympani) produce a definite pitch, but in theory they should not. At least the simplest mathematical model of a kettledrum would not have a definite pitch. Of course there are more accurate theories that align with reality. Unlike many things that work in theory but not in practice, kettledrums work in practice but not in theory. […]
How to create Green noise in Python
This is a follow-on to my previous post on green noise. Here we create green noise with Python by passing white noise through a Butterworth filter. Green noise is in the middle of the audible spectrum (on the Bark scale), just where our hearing is most sensitive, analogous to the green light, the frequency where […]
Green noise and Barks
Colors of noise In a previous post I explained the rationale behind using names of colors to refer to different kinds of noise. The basis is an analogy between the spectra of sounds and the spectra of light. Red noise is biased toward the low end of the audio spectrum just as red light is […]
Consecutive pair magic square
The following magic square has a couple unusual properties. For one, numbers appear in consecutive pairs. Also, you can connect the numbers 1 through 32 in a continuous path. I found this in Before Sudoku. The authors attribute it to William Mannke, “A Magic Square.” Journal of Recreational Mathematics. 1 (3) page 139, July 1968. […]
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, […]
...464748495051525354