News

johndcook. com
johndcook. com > blog > 05/31/2026 > another-gaussian-approximation

Another Gaussian approximation

4+ hour, 56+ min ago  (115+ words) gives a fair approximation to the Gaussian density You can make the approximation much better by raising it to a power. The function gives a good lower bound and gives a good upper bound. More on that here. There are…...

Symbols: robos-nn,dcp-an
johndcook. com
johndcook. com > blog > 05/30/2026 > schwartz-zippel

Spot checking polynomial identities

21+ hour, 10+ min ago  (303+ words) If a polynomial identity holds at a few random points, it's very like true. We'll make this statement more precise, but first let's look at some applications. You may want to test an identity that naturally presents itself as a…...

Symbols: cloud-bi
johndcook. com
johndcook. com > blog > 05/29/2026 > online-one-pass-algorithms

Online (one-pass) algorithms

2+ day, 5+ hour ago  (360+ words) The variance of a set of numbers is defined as the sum of the squared distances from each point to the mean. So it would seem that you first need to calculate the mean, then go back and compute the…...

Symbols: nasdaq:oneo,nasdaq:safe,nasdaq:fnov,nasdaq:oss,nasdaq:real,nasdaq:rope
johndcook. com
johndcook. com > blog > 05/27/2026 > jensen-shannon

From Kullback-Leibler divergence to Jensen'Shannon metric

3+ day, 16+ hour ago  (203+ words) Kullback-Leibler divergence is defined for two random variables'X and Y by K-L divergence is non-negative, and it's zero if and only if X and'Y have the same distribution. But it is not a metric, for reasons explained here. For one…...

Symbols: nyse:kdp
johndcook. com
johndcook. com > blog > 05/23/2026 > hilbert-transform-as-an-infinite-matrix

Hilbert transform as an infinite matrix

1+ week, 1+ day ago  (248+ words) The previous post linked to a post I wrote a few years ago about the Hilbert transform and Fourier series. That post says that if the Fourier series of a function is then the Fourier series of its Hilbert transform…...

Symbols: nasdaq:hilb
johndcook. com
johndcook. com > blog > 05/23/2026 > real-and-imaginary-parts

Real and imaginary parts

1+ week, 1+ day ago  (231+ words) The previous post announced some notes I wrote up based on an article by Henry Baker implementing functions of a complex variable in terms of functions of a real variable. That is, it finds functions u(x, y) and v(x,…...

Symbols: nasdaq:real
johndcook. com
johndcook. com > blog > 05/22/2026 > complex-functions-real-parts

Building complex functions out of real parts

1+ week, 1+ day ago  (233+ words) A couple months ago I wrote about how to compute the sine and cosine of a complex number using only real functions of real variables using the equations You can do something analogous for all the elementary functions, though some…...

Symbols: prime-sr
johndcook. com
johndcook. com > blog > 05/19/2026 > zagiers-equation

Don Zagier's approximation of Markov's diophantine equation

1+ week, 5+ day ago  (342+ words) Markov numbers are integer solutions to The Wikipedia article on Markov numbers mentions that Don Zagier studied Markov numbers by looking the approximating equation x" +y" +z" = 3xyz+ 4/9 which is equivalent to wheref(t) is defined as arccosh(3t/2). It wasn't clear to…...

johndcook. com
johndcook. com > blog > 05/15/2026 > xorshift128-state

Recovering the state of xorshift128

2+ week, 2+ day ago  (254+ words) I've written a couple posts lately about reverse engineering the internal state of a random number generator, first Mersenne Twister then lehmer64. This post will look at xorshift128, implemented below. Recovering the internal state of the generator is simple: it's the four…...

johndcook. com
johndcook. com > blog > 05/12/2026 > c-128-bit-int

C 128-bit unsigned int literals and printing

2+ week, 5+ day ago  (207+ words) If you look very closely at my previous post, you'll notice that I initialize a 128-bit integer with a 64-bit value. The 128-bit unsigned integer represents the internal state of a random number generator. Why not initialize it to a…...

Symbols: base-16,four.l