A calculation may require only a sum of matrix entries or a few dominant directions. Computing an entire inverse or a full SVD can then do much more work than is needed. Random vectors let us estimate selected quantities through products and solves. We must specify what is random and how its error is measured.
We first estimate traces and diagonals from random probe vectors. We then compute low-rank approximations from the range of \(\bA\boldsymbol{\Omega}\) for a random matrix \(\boldsymbol{\Omega}\). Finally, we show how random sampling limits fill during Gaussian elimination on graph Laplacians, which produces a preconditioner for the conjugate gradient method.
Trace and Diagonal Estimation
The trace of \(\bA^{-1}\) and the diagonal of \(\bA^{-1}\) appear as sums of variances in statistics, as effective resistances in graphs, and as sensitivities of linear models. Computing \(\operatorname{diag}(\bA^{-1})\) exactly requires solving \(\bA\bx=\be_i\) for every \(i\). The estimators below use only products \(\bz\mapsto\bA\bz\), or solves with \(\bA\), applied to a few random vectors \(\bz\).
For independent signs \(z_i=\pm1\) with equal probability, \(z_i^2=1\) whereas \(\mathbb E[z_iz_j]=0\) for \(i\neq j\). In a quadratic form, the diagonal contributions therefore survive averaging and the off-diagonal contributions cancel in expectation. A finite average still has random error. Unbiased means its expectation is correct, not that every sample is accurate.
For \(\bA=\begin{pmatrix}2&c\\c&3\end{pmatrix}\), list the values of \(\bz^T\bA\bz\) for all four sign vectors. Compute their mean and variance. Explain why the mean is independent of \(c\) although the uncertainty is not.
Let \(\bA\in\fR^{n\times n}\) be symmetric, and let \(\bz\in\fR^n\) have independent entries with mean zero and variance one. Then \(\mathbb{E}[\bz^T\bA\bz]=\operatorname{tr}(\bA)\). If the entries of \(\bz\) are \(\pm1\) with equal probability, then \[
\begin{align}
\operatorname{Var}(\bz^T\bA\bz)=2\Big(\|\bA\|_F^2-\sum_{i=1}^na_{ii}^2\Big).
\end{align}
\] If the entries of \(\bz\) are standard normal, then \(\operatorname{Var}(\bz^T\bA\bz)=2\|\bA\|_F^2\).
Write the quadratic form as \(\bz^T\bA\bz=\sum_{i,j}a_{ij}z_iz_j\). Independence and zero means give \(\mathbb E[z_iz_j]=0\) for \(i\neq j\), while unit variance gives \(\mathbb E[z_i^2]=1\). Linearity of expectation therefore gives \[
\begin{align}
\mathbb E[\bz^T\bA\bz]=\sum_i a_{ii}=\operatorname{tr}(\bA).
\end{align}
\] This expectation argument needs no assumption about higher moments.
For independent signs, \(z_i^2=1\) on every outcome. Symmetry of \(\bA\) pairs the off-diagonal terms, so the centered estimator is \[
\begin{align}
Z=\bz^T\bA\bz-\operatorname{tr}(\bA)
=2\sum_{i<j}a_{ij}z_iz_j.
\end{align}
\] Each product has mean zero and squared value one. Two different unordered pairs have zero cross expectation. If the pairs are disjoint, all four independent factors have mean zero. If they share one index, its square is one and the two remaining independent factors each have mean zero. Thus \[
\begin{align}
\operatorname{Var}(Z)=\mathbb E[Z^2]
=4\sum_{i<j}a_{ij}^2
=2\sum_{i\neq j}a_{ij}^2.
\end{align}
\] Subtracting the diagonal squares from \(\|\bA\|_F^2\) gives the first variance formula. The products need not be independent: the zero cross expectations are sufficient.
For Gaussian probes, diagonalize \(\bA=\bQ\boldsymbol\Lambda\bQ^T\) and put \(\bg=\bQ^T\bz\). The standard Gaussian density is proportional to \(e^{-\|\bz\|_2^2/2}\). Orthogonal changes preserve both the norm and volume, so \(\bg\) has the same independent standard normal coordinates. Hence \[
\begin{align}
\bz^T\bA\bz=\sum_i\lambda_i g_i^2.
\end{align}
\] A standard normal has second moment one and fourth moment three, obtained by integration by parts against its density. Thus \(\operatorname{Var}(g_i^2)=3-1=2\). Independence makes the covariances of distinct squared coordinates zero, giving \[
\begin{align}
\operatorname{Var}(\bz^T\bA\bz)=2\sum_i\lambda_i^2=2\|\bA\|_F^2.
\end{align}
\] The sign-probe estimator is attributed to Hutchinson (1990).
Show that Hutchinson’s estimator with \(\pm1\) entries is exact for every diagonal matrix. Then show that, for every symmetric matrix, its variance is at most that of the Gaussian estimator, with equality exactly when the diagonal of \(\bA\) is zero.
Averaging \(k\) independent samples divides the variance by \(k\). For a symmetric positive semidefinite matrix, \(\|\bA\|_F^2=\sum_i\lambda_i^2\leq(\sum_i\lambda_i)^2=\operatorname{tr}(\bA)^2\), so with Gaussian probes the relative standard deviation of the averaged estimate is at most \(\sqrt{2/k}\). The error decreases like \(k^{-1/2}\), independently of \(n\), which is the usual Monte Carlo rate. One hundred probes therefore give a relative standard deviation of at most about fourteen percent, and the estimator is most useful when this accuracy is sufficient or when \(\|\bA\|_F\) is much smaller than \(\operatorname{tr}(\bA)\) (Hutchinson 1990).
Let \(\bz_1,...,\bz_k\) be independent vectors with independent \(\pm1\) entries, and let \(\odot\) denote the entrywise product. Then \[
\begin{align}
\bd_k=\frac1k\sum_{l=1}^k\bz_l\odot(\bA\bz_l)
\end{align}
\] satisfies \(\mathbb{E}[\bd_k]=\operatorname{diag}(\bA)\).
Expand entry \(i\) of \(\bz\odot(\bA\bz)\). Separate the diagonal term, use \(z_i^2=1\), and take expectations. Derive the variance of this entry and show that averaging \(k\) independent probes divides it by \(k\).
To estimate \(\operatorname{diag}(\bA^{-1})\), we replace \(\bA\bz_l\) by \(\bA^{-1}\bz_l\) (Bekas et al. 2007). One sparse factorization of \(\bA\) is computed once, and each probe then costs one pair of triangular solves. For \(k\ll n\), this replaces \(n\) solves by \(k\) solves. Bekas, Kokiopoulou, and Saad also use structured probe vectors that are orthogonal on blocks of the matrix, which removes the error from entries within those blocks.
Randomized Low-Rank Approximation
By the referenced result, the best rank-\(k\) approximation of \(\bA\) is given by its truncated SVD. Computing the full SVD of a large matrix in order to keep a few singular triplets wastes almost all of the work. If the singular values decay, the dominant left singular vectors span most of the range of \(\bA\). A product \(\bA\boldsymbol{\omega}\) with a random vector \(\boldsymbol{\omega}\) is a random combination of the columns of \(\bA\), and it lies mostly in that dominant subspace. A few such products therefore span most of the dominant range.
Let \(\bA\in\fR^{m\times n}\), let \(k\) be the target rank, and let \(p\geq2\) be an oversampling parameter with \(k+p\leq\min(m,n)\). If the sample matrix is rank deficient, retain only its independent orthonormal columns and adjust the reduced dimensions below.
Draw \(\boldsymbol{\Omega}\in\fR^{n\times(k+p)}\) with independent standard normal entries.
Form \(\bY=\bA\boldsymbol{\Omega}\) and compute its thin QR factorization \(\bY=\bQ\bR\).
Form \(\bB=\bQ^T\bA\in\fR^{(k+p)\times n}\) and compute its SVD \(\bB=\tilde{\bU}\bsigma\bV^T\).
Return the approximate SVD \(\bA\approx(\bQ\tilde{\bU})\bsigma\bV^T\), truncated to rank \(k\) if required.
Assume \(\bA\) has rank exactly \(k\) and the columns of \(\bY\) span its range. Show that \(\bQ\bQ^T\bA=\bA\), so the reduced SVD recovers the matrix exactly in exact arithmetic. For a matrix of larger rank, derive \(\bA-\bQ\bB=(\bI-\bQ\bQ^T)\bA\). What error remains before any singular values of \(\bB\) are discarded?
The algorithm touches \(\bA\) only through the two products \(\bA\boldsymbol{\Omega}\) and \(\bQ^T\bA\). For a dense matrix these cost \(O(mn(k+p))\) flops, and for a sparse matrix \(O(\operatorname{nnz}(\bA)(k+p))\). The QR factorization and the small SVD cost \(O((m+n)(k+p)^2)\). Before the final truncation, the approximation error is \(\|\bA-\bQ\bQ^T\bA\|\), because \(\bQ\tilde{\bU}\bsigma\bV^T=\bQ\bQ^T\bA\). Halko, Martinsson, and Tropp prove that \[
\begin{align}
\mathbb{E}\,\|\bA-\bQ\bQ^T\bA\|_F
\leq\Big(1+\frac{k}{p-1}\Big)^{1/2}\Big(\sum_{j>k}\sigma_j^2\Big)^{1/2}
\end{align}
\] for Gaussian \(\boldsymbol{\Omega}\) (Halko et al. 2011). The second factor is the error of the truncated SVD, so the randomized method loses at most the first factor in expectation. With \(p=k+1\), that factor is \(\sqrt2\).
(Slowly decaying singular values) When the singular values decay slowly, the range of \(\bA\boldsymbol{\Omega}\) contains significant components from the trailing singular vectors. Replacing \(\bY=\bA\boldsymbol{\Omega}\) by \(\bY=(\bA\bA^T)^q\bA\boldsymbol{\Omega}\) multiplies the \(j\)th singular direction by \(\sigma_j^{2q+1}\) and suppresses the trailing directions, exactly as in power iteration (the referenced result). In floating-point arithmetic, the columns are orthonormalized after each multiplication, because the powers otherwise become numerically dependent (Halko et al. 2011).
Random Sampling in Gaussian Elimination
the referenced section showed that eliminating a vertex joins all of its neighbors into a clique, and that the resulting fill makes sparse Cholesky expensive on large meshes. For the Laplacian of a weighted graph, the clique has an explicit form. Random sampling can replace it by a sparse graph that is correct on average.
Let \(\bL=\bD-\bW\) be the Laplacian of a connected graph with nonnegative edge weights \(w_{ij}\) and degrees \(d_i=\sum_jw_{ij}\). Eliminating vertex \(v\) produces a Schur complement that is again a graph Laplacian. Its graph is the graph of \(\bL\) with \(v\) removed, plus an edge of weight \(w_{iv}w_{jv}/d_v\) between each pair of neighbors \(i,j\) of \(v\).
Place the eliminated vertex first and write its Laplacian in blocks as \[
\begin{align}
\bL=\begin{pmatrix}d_v&\br^T\\\br&\bB\end{pmatrix},
\qquad r_i=-w_{iv}.
\end{align}
\] For a connected graph with more than one vertex, \(d_v>0\), so elimination is defined. Its Schur complement is \(\bS=\bB-\br\br^T/d_v\).
For distinct remaining indices \(i,j\), expand the entry: \[
\begin{align}
s_{ij}=-w_{ij}-\frac{(-w_{iv})(-w_{jv})}{d_v}
=-\left(w_{ij}+\frac{w_{iv}w_{jv}}{d_v}\right).
\end{align}
\] Thus a pair of neighbors acquires the additional edge weight in the statement. If either is not a neighbor, its contribution is zero. An existing edge receives that weight in addition to its previous weight.
We also check the diagonal through conservation of row sums. Removing column \(v\) from row \(i\) removes entry \(-w_{iv}\), so the row sum of \(\bB\) is \(w_{iv}\). On the other hand, \[
\begin{align}
\sum_j\frac{r_ir_j}{d_v}
=\frac{w_{iv}}{d_v}\sum_jw_{jv}=w_{iv}.
\end{align}
\] The row sum of \(\bS\) is therefore zero. Symmetry is preserved, and all off-diagonal entries are nonpositive. Its diagonal is consequently the sum of its incident edge weights, which proves that the whole Schur complement, not just its off-diagonal part, is the claimed graph Laplacian.
Let vertex \(v\) have neighbors \(1,...,\delta\) with weights \(w_i=w_{iv}\) and \(d=\sum_iw_i\). For each neighbor \(i\), draw one neighbor \(j\) with probability \(w_j/d\) and, if \(j\neq i\), add an edge between \(i\) and \(j\) with weight \(w_i/2\). The Laplacian of the resulting graph of at most \(\delta\) edges has expected value equal to the Laplacian of the clique in the referenced result.
For a unit edge between distinct vertices \(i\) and \(j\), let \(\bL_{ij}=(\be_i-\be_j)(\be_i-\be_j)^T\). The same matrix represents the edge in either order: \(\bL_{ij}=\bL_{ji}\). Define \(\bL_{ii}=\bzero\), matching the rule that a self-selection adds no edge.
For the draw associated with vertex \(i\), the event of selecting \(j\) has probability \(w_j/d\). Its contributed Laplacian is \((w_i/2)\bL_{ij}\). Taking its expectation gives \[
\begin{align}
\sum_j\frac{w_j}{d}\frac{w_i}{2}\bL_{ij}.
\end{align}
\] The Laplacian of a sum of edges is the sum of their Laplacians. Linearity of expectation therefore makes the expected total matrix \[
\begin{align}
\sum_i\sum_j\frac{w_iw_j}{2d}\bL_{ij}.
\end{align}
\] Terms with \(i=j\) are zero. For each unordered pair \(i<j\), there are two equal terms, from the draws associated with \(i\) and \(j\). Their combined coefficient is \(w_iw_j/d\). Thus the expected matrix is \[
\begin{align}
\sum_{i<j}\frac{w_iw_j}{d}\bL_{ij},
\end{align}
\] exactly the elimination clique. At most one edge is added per neighbor, so a realization has at most \(\delta\) edges before merging duplicates. This calculation proves unbiasedness only, not a bound on the error of a realization.
Verify the referenced result for a vertex with three neighbors of weights \(1\), \(2\), and \(3\) by listing every outcome of the sampling and its probability.
An unbiased clique replacement does not by itself control the accumulated error or guarantee a useful preconditioner. A single sample may even disconnect the graph. A full approximate-elimination solver therefore needs concentration estimates and a carefully designed sampling scheme. For a connected Laplacian, the solve is restricted to the subspace orthogonal to \(\mathbf1\), or one vertex is grounded, since the full matrix is singular. Kyng and Sachdeva use a refinement of this sampling, eliminate the vertices in random order, and prove that the resulting solver reaches relative accuracy \(\varepsilon\) in \(O(m\log^3n\log(1/\varepsilon))\) expected time for a graph with \(m\) edges (Kyng and Sachdeva 2016). Practical implementations eliminate vertices in minimum-degree order, which reduces fill further but is not covered by the proof.
Further Exercises
Let \(\bA\) be the one-dimensional Poisson matrix with \(n=1000\). Estimate \(\operatorname{tr}(\bA^{-1})\) with \(k=10,100,1000\) probes using one Cholesky factorization. Plot the relative error against \(k\) on logarithmic axes and compare the slope with \(-1/2\).
Construct a \(1000\times500\) matrix with singular values \(\sigma_j=2^{-j}\) and random singular vectors. Apply the referenced result with \(k=20\) and \(p=0,5,20\), and compare \(\|\bA-\bQ\bQ^T\bA\|_2\) with \(\sigma_{21}\). Repeat with \(\sigma_j=j^{-1/2}\), with and without one step of the power iteration in the remark.
Bekas, Costas, Effrosyni Kokiopoulou, and Yousef Saad. 2007. “An Estimator for the Diagonal of a Matrix.” Applied Numerical Mathematics 57 (11–12): 1214–29.
Halko, Nathan, Per-Gunnar Martinsson, and Joel A. Tropp. 2011. “Finding Structure with Randomness: Probabilistic Algorithms for Constructing Approximate Matrix Decompositions.” SIAM Review 53 (2): 217–88.
Hutchinson, M. F. 1990. “A Stochastic Estimator of the Trace of the Influence Matrix for Laplacian Smoothing Splines.” Communications in Statistics – Simulation and Computation 19 (2): 433–50.
Kyng, Rasmus, and Sushant Sachdeva. 2016. “Approximate Gaussian Elimination for Laplacians: Fast, Sparse, and Simple.” Proceedings of the 57th Annual IEEE Symposium on Foundations of Computer Science, 573–82.