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 07:02
Hermite polynomials, expected values, and integration
In the previous post, I alluded to using Hermite polynomials in conjunction with higher-order Laplace approximation. In this post I’ll expand on what that means. Hermite polynomials are orthogonal polynomials over the real line with respect to the weight given by the standard normal distribution. (There are two conventions for defining Hermite polynomials, what Wikipedia […]
Higher-order Laplace approximation
Yesterday’s post presented the most common form of Laplace approximation, the second order version, and mentioned in passing that there are higher order versions. The extension to higher order is not trivial, so post gives a high level overview of how you’d do it. The previous post looked at integrating exp( log( g(x) ) ) by […]
Laplace approximation of an integral from Bayesian logistic regression
Define and This integral comes up in Bayesian logisitic regression with a uniform (improper) prior. We will use this integral to illustrate a simple case of Laplace approximation. The idea of Laplace approximation is to approximate the integral of a Gaussian-like function by the integral of a (scaled) Gaussian with the same mode and same […]
Top five computing blog posts of 2017
These have been the most popular computing-related posts here this year. Programming language life expectancy SHA1 no longer recommended, but hardly a failure The most disliked programming language Improving on the Unix shell One practical application of functional programming I plan to post a list of the top file math-related posts soon.
Scholarship versus research
One of the things about academia that most surprised and disappointed me was the low regard for scholarship. Exploration is tolerated as long as it results in a profusion of journal articles, and of course grant money, but is otherwise frowned upon. For example, I know someone who ruined his academic career by writing a massive […]
Intellectual onramps
Tyler Cowen’s latest blog post gives advice for learning about modern China. He says that “books about sequences of dynasties are mind-numbing and not readily absorbed” and recommends finding other entry points before reading about dynasties. Find an “entry point” into China of independent intrinsic interest to you, be it basketball, artificial intelligence, Chinese opera, […]
Efficiency is not associative for matrix multiplication
Here’s a fact that has been rediscovered many times in many different contexts: The way you parenthesize matrix products can greatly change the time it takes to compute the product. This is important, for example, for the back propagation algorithm in deep learning. Let A, B, and C be matrices that are compatible for multiplication. Then (AB)C = A(BC). […]
Higher order Taylor series in several variables
Most sources that present Taylor’s theorem for functions of several variables stop at second order terms. One reason is that one or two terms are good enough for many applications. But the bigger reason is that things get more complicated when you include higher order terms. The kth order term in Taylor’s theorem is a rank k […]
How can a statistician help a lawyer?
I’ll be presenting at a webinar on Wednesday, December 13 at 1:00 PM Eastern. The title of the presentation is “Seven questions a statistician and answer for an attorney.” I will discuss, among other things, when common sense applies and when correct analysis can be counter-intuitive. There will be ample time at the end of […]
Moment generating functions and connections to other things
This post relates moment generating functions to the Laplace transform and to exponential generating functions. It also brings in connections to the z-transform and the Fourier transform. Thanks to Brian Borchers who suggested the subject of this post in a comment on a previous post on transforms and convolutions. Moment generating functions The moment generating function (MGF) of […]
Shannon wavelet
The Shannon wavelet has an interesting plot: Given the complexity of the plot, the function definition is surprisingly simple: The Fourier transform is even simpler: it’s the indicator function of [-2π, -π] ∪ [π, 2π], i.e. the function that is 1 on the intervals [-2π, -π] and [π, 2π] but zero everywhere else. The Shannon […]
Transforms and Convolutions
There are many theorems of the form where f and g are functions, T is an integral transform, and * is a kind of convolution. In words, the transform of a convolution is the product of transforms. When the transformation changes, the notion of convolution changes. Here are three examples. Fourier transform and convolution With the Fourier transform […]
Gamma function partial sums
Last week I wrote about Jentzsch’s theorem. It says that if the power series of function has a finite radius of convergence, the set of zeros of the partial sums of the series will cluster around and fill in the boundary of convergence. This post will look at the power series for the gamma function […]
Hypergeometric functions are key
From Orthogonal Polynomials and Special Functions by Richard Askey: At first the results we needed were in the literature but after a while we ran out of known results and had to learn something about special functions. This was a very unsettling experience for there were very few places to go to really learn about […]
Distribution of Fibonacci numbers mod m
The last digits of Fibonacci numbers repeat with period 60. This is something I’ve written about before. The 61st Fibonacci number is 2504730781961. The 62nd is 4052739537881. Since these end in 1 and 1, the 63rd Fibonacci number must end in 2, etc. and so the pattern starts over. It’s not obvious that the cycle should […]
A circle of zeros: Jentzsch’s theorem
Take a function that has a power series with a finite radius of convergence. Then the zeros of the partial sums will be dense around the boundary of convergence. That is Jentzsch’s theorem. Here are a couple plots to visualize Jentzsch’s theorem using the plotting scheme described in this post. First, we take the function f(z) […]
Orthogonal polynomials and the beta distribution
This post shows a connection between three families of orthogonal polynomials—Legendre, Chebyshev, and Jacobi—and the beta distribution. Legendre, Chebyshev, and Jacobi polynomials A family of polynomials Pk is orthogonal over the interval [-1, 1] with respect to a weight w(x) if whenever m ≠ n. If w(x) = 1, we get the Legendre polynomials. If w(x) = (1 […]
Runge phenomena
I’ve mentioned the Runge phenomenon in a couple posts before. Here I’m going to go into a little more detail. First of all, the “Runge” here is Carl David Tolmé Runge, better known for the Runge-Kutta algorithm for numerically solving differential equations. His name rhymes with cowabunga, not with sponge. Runge showed that polynomial interpolation […]
Twenty questions and conditional probability
The previous post compared bits of information to answers in a game of Twenty Questions. The optimal strategy for playing Twenty Questions is for each question to split the remaining possibilities in half. There are a couple ways to justify this strategy: mixmax and average. The minmax approach is to minimize the worse thing that […]
Handedness, introversion, height, blood type, and PII
I’ve had data privacy on my mind a lot lately because I’ve been doing some consulting projects in that arena. When I saw a tweet from Tim Hopper a little while ago, my first thought was “How many bits of PII is that?”. [1] π Things Only Left Handed Introverts Over 6′ 5″ with O+ […]
Pareto distribution and Benford’s law
The Pareto probability distribution has density for x ≥ 1 where a > 0 is a shape parameter. The Pareto distribution and the Pareto principle (i.e. “80-20” rule) are named after the same person, the Italian economist Vilfredo Pareto. Samples from a Pareto distribution obey Benford’s law in the limit as the parameter a goes to […]
Random number generation posts
Random number generation is typically a two step process: first generate a uniformly distributed value, then transform that value to have the desired distribution. The former is the hard part, but also the part more likely to have been done for you in a library. The latter is relatively easy in principle, though some distributions […]
Quantifying information gain in beta-binomial Bayesian model
The beta-binomial model is the “hello world” example of Bayesian statistics. I would call it a toy model, except it is actually useful. It’s not nearly as complicated as most models used in application, but it illustrates the basics of Bayesian inference. Because it’s a conjugate model, the calculations work out trivially. For more on […]
Big aggregate queries can still violate privacy
Suppose you want to prevent your data science team from being able to find out information on individual customers, but you do want them to be able to get overall statistics. So you implement two policies. Data scientists can only query aggregate statistics, such as counts and averages. These aggregate statistics must be based on […]
Visualizing complex functions
It’s easy to visualize function from two real variables to one real variable: Use the function value as the height of a surface over its input value. But what if you have one more dimension in the output? A complex function of a complex variable is equivalent to a function from two real variables to two […]
Why is Kullback-Leibler divergence not a distance?
The Kullback-Leibler divergence between two probability distributions is a measure of how different the two distributions are. It is sometimes called a distance, but it’s not a distance in the usual sense because it’s not symmetric. At first this asymmetry may seem like a bug, but it’s a feature. We’ll explain why it’s useful to measure […]
Wheels about to be reinvented
As companies get into data analysis for the first time, many of them are going to start by making the same mistakes that were common a century ago, then gradually recapitulate the development of modern statistics.
Chebyshev interpolation
Fitting a polynomial to a function at more points might not produce a better approximation. This is Faber’s theorem, something I wrote about the other day. If the function you’re interpolating is smooth, then interpolating at more points may or may not improve the fit of the interpolation, depending on where you put the points. […]
Fourier-Bessel series and Gibbs phenomena
Fourier-Bessel series are analogous to Fourier series. And like Fourier series, they converge pointwise near a discontinuity with the same kind of overshoot and undershoot known as the Gibbs phenomenon. Fourier-Bessel series Bessel functions come up naturally when working in polar coordinates, just as sines and cosines come up naturally when working in rectangular coordinates. […]
Animated exponential sum
I’m experimenting with making animated versions of the kinds of images I wrote about in my previous post. Here’s an animated version of the exponential sum of the day for 12/4/17. Why that date? I wanted to start with something with a fairly small period, and that one looked interesting. I’ll have to do something […]
Database anonymization for testing
How do you create a database for testing that is like your production database? It depends on in what way you want the test database to be “like” the production one. Replacing sensitive data Companies often use an old version of their production database for testing. But what if the production database has sensitive information […]
Recent exponential sums
The exponential sum of the day draws a line between consecutive partial sums of where m, d, and y are the current month, day, and two-digit year. The four most recent images show how different these plots can be. These images are from 10/30/17, 10/31/17, 11/1/17, and 11/2/17. Consecutive dates often produce very different images for a couple […]
Yogi Berra meets Pafnuty Chebyshev
I just got an evaluation copy of The Best Writing on Mathematics 2017. My favorite chapter was Inverse Yogiisms by Lloyd N. Trefethen. Trefethen gives several famous Yogi Berra quotes and concludes that Yogiisms are statements that, if taken literally, are meaningless or contradictory or nonsensical or tautological—yet nevertheless convey something true. An inverse yogiism is […]
The most disliked programming language
According to this post from Stack Overflow, Perl is the most disliked programming language. I have fond memories of writing Perl, though it’s been a long time since I used it. I mostly wrote scripts for file munging, the task it does best, and never had to maintain someone else’s Perl code. Under different circumstances […]
Poisson distribution and prime numbers
Let ω(n) be the number of distinct prime factors of x. A theorem of Landau says that for N large, then for randomly selected positive integers less than N, ω-1 has a Poisson(log log N) distribution. This statement holds in the limit as N goes to infinity. Apparently N has to be extremely large before […]
US Counties and power laws
Yesterday I heard that the county I live in, Harris County, is the 3rd largest is the United States. (In population. It’s nowhere near the largest in area.) Somehow I’ve lived here a couple decades without knowing that. Houston is the 4th largest city in the US, so it’s no shock that Harris County the […]
Paul Klee meets Perry the Platypus
I was playing around with something in Mathematica and one of the images that came out of it surprised me. It’s a contour plot for the system function of a low pass filter. H[z_] := 0.05634*(1 + 1/z)*(1 - 1.0166/z + 1/z^2) / ((1 - 0.683/z)*(1 - 1.4461/z + 0.7957/z^2)) ContourPlot[ Arg[H[Exp[I (x + I […]
Differential equations and recurrence relations
Series solutions to differential equations can be grubby or elegant, depending on your perspective. Power series solutions At one level, there’s nothing profound going on. To find a series solution to a differential equation, assume the solution has a power series, stick the series into the equation, and solve for the coefficients. The mechanics are […]
Finding numbers in pi
You can find any integer you want as a substring of the digits in π. (Probably. See footnote for details.) So you could encode a number by reporting where it appears. If you want to encode a single digit, the best you can do is break even: it takes at least one digit to specify […]
Empirically testing the Chowla conjecture
Terry Tao’s most recent blog post looks at the Chowla conjecture theoretically. This post looks at the same conjecture empirically using Python. (Which is much easier!) The Liouville function λ(n) is (-1)Ω(n) where Ω(n) is the number of prime factors of n counted with multiplicity. So, for example, Ω(9) = 2 because even though 9 […]
Time series analysis vs DSP terminology
Time series analysis and digital signal processing are closely related. Unfortunately, the two fields use different terms to refer to the same things. Suppose you have a sequence of inputs x[n] and a sequence of outputs y[n] for integers n. Moving average / FIR If each output depends on a linear combination of a finite number of previous […]
How to eliminate the first order term from a second order ODE
Authors will often say that “without loss of generality” they will assume that a differential equation has no first order derivative term. They’ll explain that there’s no need to consider because a change of variables can turn the above equation into one of the form While this is true, the change of variables is seldom […]
Common words that have a technical meaning in math
Mathematical writing is the opposite of business writing in at least one respect. Math uses common words as technical terms, whereas business coins technical terms to refer to common ideas. There are a few math terms I use fairly often and implicitly assume readers understand. Perhaps the most surprising is almost as in “almost everywhere.” […]
A uniformly distributed sequence
If you take the fractional parts of the set of numbers {n cos nx : integer n > 0} the result is uniformly distributed for almost all x. That is, in the limit, the number of times the sequence visits a subinterval of [0, 1] is proportional to the length of the interval. (Clearly it’s not true […]
Applying probability to non-random things
Probability has surprising uses, including applications to things that absolutely are not random. I’ve touched on this a few times. For example, I’ve commented on how arguments about whether something is really random are often moot: Random is as random does. This post will take non-random uses for probability in a different direction. We’ll start […]
Misplacing a continent
There are many conventions for describing points on a sphere. For example, does latitude zero refer to the North Pole or the equator? Mathematicians tend to prefer the former and geoscientists the latter. There are also varying conventions for longitude. Volker Michel describes this clash of conventions colorfully in his book on constructive approximation. Many […]
Quaint supercomputers
The latest episode of Star Trek Discovery (S1E4) uses the word “supercomputer” a few times. This sounds jarring. The word has become less common in contemporary usage, and seems even more out of place in a work of fiction set more than two centuries in the future. According to Google’s Ngram Viewer, the term “supercomputer” […]
Exponential sum of the day
I’ve written a page that will show a different exponential sum each day, images along the line of the post Exponential sums make pretty pictures. Here’s page: https://www.johndcook.com/expsum/ Here are a few sample images. Small changes in the coefficients can make a big change in the appearance of the graphs.
Something that bothers me about deep neural nets
Overfitting happens when a model does too good a job of matching a particular data set and so does a poor job on new data. The way traditional statistical models address the danger of overfitting is to limit the number of parameters. For example, you might fit a straight line (two parameters) to 100 data […]
Exponential sums make pretty pictures
Exponential sums are a specialized area of math that studies series with terms that are complex exponentials. Estimating such sums is delicate work. General estimation techniques are ham-fisted compared to what is possible with techniques specialized for these particular sums. Exponential sums are closely related to Fourier analysis and number theory. Exponential sums also make […]
...40414243444546474849...