Cholesky decomposition: how do you mix independent noise?
The question
Can you mix independent inputs to match a target covariance?
Set the weights and check them on the same cloud of inputs.
- 1 SeeFill the entries of a triangular mixer.
- 2 TryPredict a pivot and test its limits.
- 3 ProveBuild the factor one entry at a time.
- 4 ApplyUse the factor for noise and equations.
Before you start · 3 quick checks on transpose, covariance, and signs of quadratic forms
Two ideas before you start
2 ideasEach row tells you what goes into one output
The first row uses the first input. The second row can use both inputs.
A lower-triangular mixer reads inputs in order. The first output uses the first input, and the second can use both.
Exact definition
Let \(Z=(Z_1,Z_2)^\mathsf T\) be a column of inputs. Write \(a,b,d\) for the entries on or below the diagonal of the real matrix \(L\).
\[\begin{aligned} L&=\begin{pmatrix}a&0\\b&d\end{pmatrix},\\ X&=LZ,\\ X_1&=aZ_1,\\ X_2&=bZ_1+dZ_2. \end{aligned}\]Lower triangular means the entries above the diagonal are zero. We use \(a\gt0\) and \(d\ge0\) in the two-input activity.
A covariance matrix gives spread and co-movement
A diagonal entry gives a variance. An off-diagonal entry gives a covariance.
A variance measures the spread of one variable. Covariance measures how two variables move together around their means.
Exact definition
For real random variables \(U,V\) with finite second moments, covariance is the expected product of the deviations \(U-\mathbb E[U]\) and \(V-\mathbb E[V]\). The variance of \(U\) is \(\operatorname{Cov}(U,U)\). In a covariance matrix, row \(i\) and column \(j\) meet at the covariance of variables \(i\) and \(j\). Switching the variables leaves the product unchanged, so the matrix is symmetric.
Correlation is covariance divided by the product of the standard deviations. It is defined when both variances are positive. See covariance and correlation.
Fine print on the inputs
The clouds use pairs of independent standard normal draws. Each input has population mean zero and variance one. Standard normal means a normal distribution with that mean and variance. The two inputs have zero population covariance by independence. For the covariance calculation alone, centered inputs with unit variances and zero covariance suffice.
Each dot represents one pair of draws. The goal concerns the population covariance, meaning the covariance under the model before a finite sample is drawn. The points let you see what one finite sample from that model can look like.
Build a mixer for the target
- Fill \(a,b,d\) on and below the diagonal. The entry above the diagonal is fixed at zero.
- Press Check my mixer to transform the input cloud and score your attempt. Match both variances and the covariance.
How the game scores a mixer
The sample score shows the gap between your cloud’s Pearson correlation and the target correlation. Pearson correlation uses the deviations from the cloud’s coordinate means. A finite cloud can have a different correlation from the population even when the mixer is exact. If one output is constant, the sample correlation is undefined.
The match score uses the population entries calculated from your mixer. A correlation can stay the same when you scale a variable by a positive constant, even though the variance changes. That is why a small sample gap alone cannot win the game.
How much room is left for the second input?
- Predict the second diagonal entry for a new target with unit variances.
- After checking, move the requested correlation and watch what happens to the second pivot.
Check your prediction to open the explorer.
Keep both variances at one and let the requested covariance be \(\rho\). When the request is feasible, this covariance is also the population correlation. The second pivot here means the amount inside the square root for \(d\), namely \(1-\rho^2\).
Goals
What the boundary means
For this family the vectors \((1,1)^\mathsf T\) and \((1,{-1})^\mathsf T\) are eigenvectors with eigenvalues \(1+\rho\) and \(1-\rho\). The explorer uses nonnegative \(\rho\), so the second is the smaller eigenvalue. The second pivot and the smaller eigenvalue vanish at the same boundary in this family, although their values away from it can differ.
A zero eigenvalue lets the cloud lie on a line. Here the second output can use the first input alone and still have variance one. A negative pivot at \(L_{22}\) calls for the square root of a negative number. In this family the same request would give \(X_1-X_2\) a negative variance. See positive semidefinite matrices for how this test extends to several correlations.
Find each entry from the target
Let \(v,c,w\) be real with \(v\gt0\), and set \(\Sigma=\begin{pmatrix}v&c\\c&w\end{pmatrix}\). The target entries are first variance \(v\), covariance \(c\), and second variance \(w\) when \(\Sigma\) is a covariance matrix. Define \(s=w-c^2/v\).
There is a real lower-triangular \(L\) with \(a\gt0\), \(d\ge0\), and \(\Sigma=LL^\mathsf T\) exactly when \(s\ge0\). When it exists it is unique in this convention. It has both diagonal entries positive exactly when \(\Sigma\) is positive definite, meaning \(x^\mathsf T\Sigma x\gt0\) for every nonzero real column \(x\).
Match the entries in order. In the first three lines the matching equations are necessary conditions for a factor. Then use those conditions to decide when the factor exists.
The determinant gives another way to see the boundary. With \(v\gt0\),
\[\det\Sigma=vw-c^2=v s.\]The sign of the determinant is the sign of the pivot \(s\). With a real factor, \(\det(LL^\mathsf T)=(ad)^2\). If the pivot is zero, the second column of \(L\) vanishes and there is just one input direction contributing to the output.
Let \(Z\) have mean zero, finite second moments, unit variances, and zero covariance between distinct coordinates. Then \(\mathbb E[ZZ^\mathsf T]=I\), the identity matrix. For \(X=LZ\) with a fixed real \(L\), the mean remains zero and
\[\begin{aligned} \operatorname{Cov}(X)&=\mathbb E[XX^\mathsf T]\\ &=L\mathbb E[ZZ^\mathsf T]L^\mathsf T\\ &=LL^\mathsf T. \end{aligned}\]Independent standard normal entries give a jointly normal output. With a singular factor this includes a degenerate normal distribution supported on a lower-dimensional subspace.
More than two inputs
For a real symmetric positive definite matrix, split off the first row and column. Write the first entry as \(v\), the column below it as \(r\), and the remaining square block as \(B\). Then the first factor column has top entry \(\sqrt v\) and lower block \(r/\sqrt v\). The smaller target is \(B-rr^\mathsf T/v\), called the Schur complement.
For any nonzero vector \(y\) in the smaller space, evaluate the original quadratic form at \((-r^\mathsf T y/v,y)\). The result is \(y^\mathsf T(B-rr^\mathsf T/v)y\gt0\), so the smaller matrix is positive definite. The one-entry case is a positive square root. Repeating the split proves existence by induction. It also proves uniqueness among factors with positive diagonal entries, since the first column is forced and the smaller factor is unique.
For a positive semidefinite target a diagonal may vanish. A routine that divides by that diagonal needs special handling. A symmetric positive semidefinite matrix also has a symmetric square root built from its orthogonal eigenvectors and the square roots of its eigenvalues. Compare the treatment of zero stretches in singular value decomposition.
Problems
Work from a target covariance, read a correlation from a factor, and use a factor to solve a system. Each problem has hints and a worked solution.
Further reading
- G. H. Golub and C. F. Van Loan, Matrix Computations, on Cholesky factorization and triangular solves.
- N. J. Higham, Accuracy and Stability of Numerical Algorithms, on numerical stability of Cholesky factorization.