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 12:16
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 […]
Regular expression to match any chemical element
Here’s a frivolous exercise in regular expressions: Write a regex to match any chemical element symbol. Here’s one solution. A[cglmrstu]|B[aehikr]?|C[adeflmnorsu]?|D[bsy]|E[rsu]|F[elmr]?|G[ade]|H[efgos]?|I[nr]?|Kr?|L[airuv]|M[dgnot]|N[abdeiop]?|Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehilm]|U(u[opst])?|V|W|Xe|Yb?|Z[nr] Making it more readable Here’s the same expression in more readable form: / A[cglmrstu] | B[aehikr]? | C[adeflmnorsu]? | D[bsy] | E[rsu] | F[elmr]? | G[ade] | H[efgos]? | I[nr]? | Kr? | L[airuv] | […]
Discrete harmonic functions
A (continuous) harmonic function f on an open set a function that is twice differentiable and satisfied Laplace’s equation: ∇2 f = 0. Such functions have a mean value property: at a point x interior to the set, f(x) equals the average value of f over any ball around x that fits inside the region. It turns out that the […]
Mathematics of medical plastics
In this interview, I talk with Ray Rilling about applying mathematics to manufacturing medical plastics. JC: Ray, could you start by saying a little about yourself? RR: Sure. My name is Ray Rilling, and I am the Director of Technology at Putnam Plastics. My initial training was cellular biology with an emphasis on epidemiology, but […]
Hypergeometric bootstrapping: implement one, get seven free
Suppose you have software to compute one hypergeometric function. How many more hypergeometric functions can you compute from it? Hypergeometric functions satisfy a lot of identities, so you can bootstrap one such function into many more. That’s one reason they’re so useful in applications. For this post, I want to focus on just three formulas, the so-called […]
Can you hear the shape of a network?
Mark Kac asked in 1966 whether you can hear the shape of a drum. In other words, can two drums, made of the same material, produce the exact same sound but have different shapes? More formally, Kac asked whether the eigenvalues of the Laplace’s equation with zero boundary conditions uniquely determine the shape of a […]
Discrete Laplace transform
The relationship between the discrete Laplace transform and discrete Fourier transform is not quite the same as that between their continuous counterparts. Continuous Fourier and Laplace transforms The continuous versions of the Fourier and Laplace transforms are given as follows. Fourier transform: Laplace transform: The Fourier transform is defined several ways, and I actually prefer […]
Reproducible randomized controlled trials
“Reproducible” and “randomized” don’t seem to go together. If something was unpredictable the first time, shouldn’t it be unpredictable if you start over and run it again? As is often the case, we want incompatible things. But the combination of reproducible and random can be reconciled. Why would we want a randomized controlled trial (RCT) to […]
Joukowsky transformation
The Joukowsky transformation, or Joukowsky map, is a simple function that comes up in aerospace and electrical engineering calculations. (Here z is a complex variable.) Despite its simplicity, it’s interesting to look at in detail. Mapping lines and circles Let z = r exp(iθ) and let w = u + iv be its image. Writing the Joukowsky transformation in terms of its real and complex parts makes it […]
General birthday problem
The birthday problem, sometimes called the birthday paradox, says that it’s more likely than you’d expect that two people in a group have the same birthday. Specifically, in a random sample of 23 people, there’s about a 50-50 chance that two people share the same birthday. The birthday problem makes a nice party trick, but […]
Random number generator seed mistakes
Long run or broken software? I got a call one time to take a look at randomization software that wasn’t randomizing. My first thought was that the software was working as designed, and that the users were just seeing a long run. Long sequences of the same assignment are more likely than you think. You […]
Bounding a graph’s diameter by its spectrum
You can get upper and lower bounds on the diameter of a connected graph G from its spectrum. If G has r distinct eigenvalues—whether of the adjacency matrix A, Laplacian L, or signless Laplacian Q—then the its diameter d is at most r-1. (Definitions of these matrices here.) If G has n vertices then we […]
Graph regularity and Laplace eigenvalues
You can tell whether a graph is regular, or nearly regular, by looking at its eigenvalues. Let G be a graph with n vertices and m edges and let L be the Laplacian matrix of G. Then the sum of the eigenvalues of L is 2m. (The diagonal of L contains the degrees of each node, so it’s trace is twice the […]
Next areas of math to be applied
Not that long ago number theory was considered strictly pure math. Then came applications to cryptography. Now number theory is at the foundation of the online economy. What are the next areas of pure math to find widespread application? Some people are saying algebraic topology and category theory. [I saw a cartoon to this effect the other day […]
Compressing ten years into six months
The other day I ran across a line from Peter Thiel saying that if you have a plan for where you’d like to be in ten years, ask yourself if you could get there in six months. I don’t think he’s simply saying see if you can do everything 20 times faster. If you estimate something […]
Golden ratio series
Here are a couple elegant series involving the golden ratio φ = (1 + √5)/2. First, reciprocals of integer powers: Then reciprocals of odd powers: Both are easy to prove since they’re geometric series. More posts related to the golden ratio: Imaginary gold Oscillating Fibonacci ratios Golden strings and the rabbit constant Power method and […]
Understanding a graph by peeling away nodes
One way to get some understanding of a graph is to peel away nodes, starting with the least connected. The k-core of a graph is the maximal subgraph such that every vertex has degree at least k. The k-shell is the set of vertices that are part of the k-core but not part of the […]
New prime number record
Last year I wrote a couple posts about what was then the largest known prime, 257885161 – 1. Now there’s a new record, P = 274207281 – 1. For most of the last 500 years, the largest known prime has been a Mersenne prime, a number of the form 2p – 1 where p is itself prime. Such numbers […]
Bipartite graphs and the signless Laplacian
The vertices of a bipartite graph can be divided into two sets where edges only go from one set to the other; there are no edges within each set. For example, in the graph below edges connect blue to green nodes, but not blue to blue or green to green. In this example there are two […]
Spectra of random graphs
Create a graph by first making a set of n vertices and then connecting nodes i and j, i > j, with probability p. This is known as the Erdős-Rényi graph Gn,p. Here’s such a graph with n = 100 and p = 0.1. Then the spectrum of the adjacency matrix A of the graph bounces around the spectrum of the expected […]
Matrix Pythagorean Triples
A Pythagorean triple is a list of positive integers (a, b, c) such that a2 + b2 = c2. Euclid knew how to find all Pythagorean triples: pick two positive integers m and n with m > n and let a = m2 – n2, b = 2mn, c = m2 + n2. Now what if we look at matrices with […]
Visualizing search keyword overlap
The other day someone asked me to look at the search data for Debug Pest Control, a pest management company based in Rhode Island. One of the things I wanted to visualize was how the search terms overlapped with each other. To do this, I created a graph where the nodes are the keywords and edges join nodes that […]
Spectral coordinates in Python
A graph doesn’t have any geometric structure unless we add it. The vertices don’t come with any position in space. The same graph can look very different when arranged different ways. Spectral coordinates are a natural way to draw a graph because they are determined by the properties of the graph, not arbitrary aesthetic choices. Construct the Laplacian […]
Magic square made of dominoes
You can arrange a standard set of dominoes into a magic square of sorts. There are 28 dominoes, each with two ends, so the number of ends isn’t a perfect square. But if you ignore the row of blanks at the bottom, you have a 7 by 7 square where every row, column, and diagonal […]
Seven questions a statistician could answer for a lawyer
A statistician could help a lawyer answer the following questions. Was this data collected in a proper way? Does common sense apply here, or is there something subtle going on? What conclusions can we draw from the data? Is this analysis routine or is there something unusual about it? How much confidence can we place […]
Visualizing the DFT matrix
The discrete Fourier transform (DFT) of length N multiplies a vector by a matrix whose (j, k) entry is ωjk where ω = exp(-2πi/N), with j and k running from 0 to N – 1. Each element of the matrix is a rotation, so if N = 12, we can represent each element by an hour on a clock. The angle […]
Spectra of complete graphs, stars, and rings
A few examples help build intuition for what the eigenvalues of the graph Laplacian tell us about a graph. The smallest eigenvalue is always zero (see explanation in footnote here). For a complete graph on n vertices, all the eigenvalues except the first equal n. The eigenvalues of the Laplacian of a graph with n […]
Adding an edge increases eigenvalues
When you add an edge to a graph, each of the eigenvalues of the graph Laplacian either increases or stays the same. As I wrote in my previous post, the smallest eigenvalue is always 0. The second smallest eigenvalue is 0 if and only if the graph is disconnected. So no edge will increase the […]
Measuring connectivity with graph Laplacian eigenvalues
If a graph can be split into two components with no links between them, that’s probably easy to see. It’s also unlikely, unless there’s a good reason for it. The less obvious and more common case is a graph that can almost be split into two components. Spectral graph theory, looking at the eigenvalues of the graph Laplacian, […]
Big p, Little n
Statisticians use n to denote the number of subjects in a data set and p to denote nearly everything else. You’re supposed to know from context what each p means. In the phrase “big n, little p” the symbol p means the number of measurements per subject. Traditional data sets are “big n, little p” […]
Connecting on LinkedIn
I only connect to people on LinkedIn that I know. This almost always means people I have met face-to-face or at least talked to over the phone. If you’d like to connect on LinkedIn and we haven’t met, please contact me to set up a phone call. I look forward to talking to you.
Relating Fourier series and Fourier transforms
Fourier series and Fourier transforms may seem more different than they are because of the way they’re typically taught. Fourier series are presented more as a representation of a function, not a transformation. Here’s a function on an interval. We can write it as a sum of sines and cosines, just as we can write […]
An example of coming full circle
Here’s an interesting line from Brad Osgood: Isn’t it a little embarrassing that multibillion dollar industries seem to depend on integrals that don’t converge? In context, he’s not saying that huge companies are blithely using bad math. Some are, but that’s not what he’s getting at here. His discussion is an example of coming full […]
Finding 2016 in pi
2016 appears in π starting at the 7173rd decimal place: You can confirm this with Mathematica or Wolfram Alpha: Mod[ Floor[10^7177 pi] , 10000] I found it using the following Python code: >>> from sympy import pi >>> digits = str(pi.evalf(10000))[2:] >>> digits.find('2016') 7173 By the way, it’s also true that 2016 = 1 + 2 […]
Get rid of something every Thursday
I heard of someone who had a commitment to get rid of something every Thursday. I don’t know anything about how they carried that out. It could mean throwing out or donating to charity a physical object each Thursday. Or maybe it could be handing over a responsibility or letting go of an ambition. It could be a […]
Most popular posts of 2015
Here are this blog’s most popular technology posts of 2015: The most important skill in software development Automate to save mental energy, not time The success of object oriented programming Learning (needlessly) hard technology And here are the most popular math posts of 2015: Defining zero factorial Life lessons from differential equations Distance to Mars
Automate to save mental energy, not time
Automation doesn’t always save as much time or effort as we expect. The xkcd cartoon above is looking at automation as an investment. Does the work I put in now eventually save more work than I put into it? Automation may be well worth it even if the answer is “no.” Automation can be like […]
The Dirac comb or Sha function
The sha function, also known as the Dirac comb, is denoted with the Cyrillic letter sha (Ш, U+0428). This letter was chosen because it looks like how people visualize the function, a long series of vertical spikes. The function is called the Dirac comb for the same reason. This function is very important in Fourier […]
The longer it has taken, the longer it will take
Suppose project completion time follows a Pareto (power law) distribution with parameter α. That is, for t > 1, the probability that completion time is bigger than t is t-α. (We start out time at t = 1 because that makes the calculations a little simpler.) Now suppose we know that a project has lasted […]
Two meanings of distribution
There are a couple common uses of the term distribution in math. The most familiar is probability distribution, such as a beta distribution, a Poisson distribution, etc. Less familiar but still common is distributions in the sense of generalized functions, like the Dirac delta distribution. Anybody with much exposure to math will have heard of a […]
Restarting @DSP_fact, ending @PerlRegex
I’m making a couple changes to my Twitter accounts. First, I’m winding down @PerlRegex. I’ll stop tweeting there when my scheduled tweets run out. I suggest that everyone who has been following @PerlRegex start following @RegexTip instead. The latter is more general, but is mostly compatible with Perl. Second, I’m reviving my @DSP_Fact. I stopped […]
Retooling
I was listening to a classic music station yesterday, and I heard the story of a professional pianist whose hand was injured in an accident. He then started learning trumpet and two years later he was a professional trumpeter. I didn’t catch the musician’s name. I was not surprised that a professional in one instrument could become […]
...4748495051525354