2025-11-12 22:55:40
The mth elementary symmetric polynomial of degree n
is the sum of all terms containing a product of m variables. So, for example,
These polynomials came up in the previous post. The problem was choosing weights to minimize the variance of a weighted sum of random variables can be solved using elementary symmetric polynomials.
To state the optimization problem more generally, suppose you want to minimize
where the ti and xi are positive and the ti sum to 1. You can use Lagrange multipliers to show that the solution is
2025-11-12 21:02:54
Suppose you have $100 to invest in two independent assets, A and B, and you want to minimize volatility. Suppose A is more volatile than B. Then putting all your money on A would be the worst thing to do, but putting all your money on B would not be the best thing to do.
The optimal allocation would be some mix of A and B, with more (but not all) going to B. We will formalize this problem and determine the optimal allocation, then generalize the problem to more assets.
Let X and Y be two independent random variables with finite variance and assume at least one of X and Y is not constant. We want to find t that minimizes
subject to the constraint 0 ≤ t ≤ 1. Because X and Y are independent,
Taking the derivative with respect to t and setting it to zero shows that
So the smaller the variance on Y, the less we allocate to X. If Y is constant, we allocate nothing to X and go all in on Y. If X and Y have equal variance, we allocate an equal amount to each. If X has twice the variance of Y, we allocate 1/3 to X and 2/3 to Y.
Now suppose we have n independent random variables Xi for i running from 1 to n, and at least one of the variables is not constant. Then we want to minimize
subject to the constraint
and all ti non-negative. We can solve this optimization problem with Lagrange multipliers and find that
for all 1 ≤ i, j ≤ n. These (n − 1) equations along with the constraint that all the ti sum to 1 give us a system of equations whose solution is
Incidentally, the denominator has a name: the (n − 1)st elementary symmetric polynomial in n variables. More on this in the next post.
2025-11-11 03:14:08
Excellent video by Almost Sure: What does Riemann Zeta have to do with Brownian Motion?
Connects several things that I’ve written about here including Brownian motion, the Riemann zeta function, and the Kolmogorov-Smirnov test.
The post Brownian motion and Riemann zeta first appeared on John D. Cook.2025-11-10 02:54:29
Suppose you have data on the closing prices of two stocks over 1,000 days and you want to look at the correlation between the two asset prices over time in rolling 30 day windows.

It seems that the rolling correlation is periodic. peaking about every 50 days.
But this is an artifact of the rolling window, not a feature of the data. I created the two simulated stock time series by creating random walks. The price of the stock each day is the price the previous day plus a sample from a normal random variable with mean zero and variance 1.

import numpy as np from scipy.stats import norm n = 1000 x = np.cumsum(norm.rvs(size=n)) y = np.cumsum(norm.rvs(size=n))
If you use a wider window, say 60 days, you’ll still see a periodic pattern in the rolling correlation, though with lower frequency.
2025-11-09 09:47:51
The area of a triangle can be computed directly from the lengths of its sides via Heron’s formula.
Here s is the semiperimeter, s = (a + b + c)/2.
Is there an analogous formula for spherical triangles? It’s not obvious there should be, but there is a formula by Simon Antoine Jean L’Huilier (1750–1840).
Here we denote area by S for surface area, rather than A because in the context of spherical trigonometry A usually denotes the angle opposite side a. The same convention applies in plane trigonometry, but the potential for confusion is greater in L’Huilier’s formula since the area appears inside a tangent function.
Now tan θ ≈ θ for small θ, and so L’Huilier’s formula reduces to Heron’s formula for small triangles.
Imagine the Earth as a sphere of radius 1 and take a spherical triangle with one vertex at the north pole and two vertices on the equator 90° longitude apart. Then a = b = c = π/2 and s = 3π/4. Such a triangle takes of 1/8 of the Earth’s surface area of 4π, so the area S is π/2. You can verify that L’Huilier’s formula gives the correct area.
It’s not a proof, but it’s a good sanity check that L’Huilier’s formula is correct for small triangles and for at least one big triangle.
The post Analog of Heron’s formula on a sphere first appeared on John D. Cook.2025-11-07 22:01:03
There’s increasing talk of gigawatt data centers. Currently the largest data center, Switch’s Citadel Campus in Nevada, uses 850 megawatts of power. OpenAI’s Stargate data center, under construction, is supposed to use 1.2 gigawatts.
An average French nuclear reactor produces about a gigawatt of power. If the US were allowed build nuclear reactors, we could simply build one reactor for every gigantic data center. Unfortunately, the Nuclear Regulatory Commission essentially prohibits the construction of profitable nuclear reactors.
An American home uses about 1200 watts of power, so a gigawatt of electricity could power 800,000 homes. So roughly, a gigawatt is a megahome.
A gigawatt is a unit of power, not energy. Energy is power over some time period.
A gigwatt-year is about 3 × 1016 joules, or 30 petajoules.
A SpaceX Starship launch releases 50 terajoules of energy, so a gigawatt-year is 60 Starship launches.
A couple months ago I wrote about illustrating crypographic strength in terms of the amount of energy needed to break it, and how much water that much energy would boil. Let’s do something similar for a gigawatt-year.
It takes about 300 kilojoules of energy to boil a liter of water [1], so 30 petajoules would boil 100 billion liters of water. So a gigawatt-year of energy would be enough to boil Coniston Water, the third largest lake in England.
If you could convert a kilogram of matter to energy according to E = mc², this would release 90 petajoules. So a gigawatt-year is the energy in about 300 grams of matter.
[1] In detail, boiling a liter of water is defined as increases the temperature from 20° C to 100° C at sea level.
The post How much is a gigawatt? first appeared on John D. Cook.