A stochastic process on an interval is a random function, and a random function is a point in an infinite-dimensional space. The Karhunen-Loeve expansion gives that space its natural coordinates. It writes the process as a series in a fixed orthonormal basis with random coefficients, and the basis it chooses is the eigenbasis of the process's own covariance, the unique basis that makes the coefficients uncorrelated and concentrates the variance into as few terms as possible. It is principal component analysis for functions, and it is the bridge between the spectral theory of operators and the second-order theory of processes [1], [2].
#The covariance operator
Let be a centered second-order process, and , with covariance continuous on , which holds when is mean-square continuous. The covariance defines an integral operator on ,
The operator is self-adjoint, positive, and compact on . Its eigenvalues are nonnegative and accumulate only at zero, and its eigenfunctions form an orthonormal basis of the closure of the range.
Self-adjointness follows from the symmetry , since . Positivity follows from
the kernel being the covariance of the linear functional . The interchange of the expectation and the double integral is licensed by , using Cauchy-Schwarz and the continuity of on the compact square. Compactness follows because that same continuity makes square-integrable and a Hilbert-Schmidt operator, hence compact. The spectral theorem for compact self-adjoint operators then supplies a real eigenvalue sequence accumulating only at zero with orthonormal eigenfunctions spanning the closed range, and positivity makes every eigenvalue nonnegative.
The eigenvalue equation is the Fredholm problem , and the pairs are the spectral data of the process.
#Mercer's theorem
The spectral data reconstruct the covariance itself, not merely its action on functions.
For a continuous, positive semidefinite covariance (positivity from Equation (2), where operator positivity upgrades to pointwise PSD by taking as approximate identities concentrated at the with weights and passing to the limit through the continuity of ), the eigen-expansion
converges absolutely and uniformly on [3].
The proof runs in two steps. On the diagonal, is continuous, decreasing in , and tends to pointwise, since by the spectral expansion of the positive operator, so Dini's theorem on the compact gives uniformly. Off the diagonal, Cauchy-Schwarz bounds the tail of Equation (3) by , whose first factor tends to uniformly by the diagonal step while is bounded on the compact diagonal, so the series converges absolutely and uniformly on . Setting gives the trace identity
where the exchange is Tonelli, since is nonnegative and jointly measurable (measurability from mean-square continuity) and is finite by continuity of on the compact diagonal. So the eigenvalues sum to the total variance of the process, the energy that the expansion below distributes across its coordinates.
#The expansion
Define the coefficients for . Then the are centered, uncorrelated, and of unit variance, and
the series converging in mean square uniformly in .
Centering is immediate from . For the second moments,
using the eigen-equation and the orthonormality of the eigenfunctions, so the coefficients are uncorrelated with unit variance. Pulling the expectation inside the product of time integrals is the same Fubini bound as Equation (2), since by Cauchy-Schwarz and continuity of on the compact square. Let be the partial sum. Then
The middle term is , since (the interchange of with the time integral defining is the same Fubini/Cauchy-Schwarz bound as Equation (2), as and with continuous on the compact square), and the last term is because the coefficients are uncorrelated of unit variance. Substituting into Equation (7),
which is exactly the diagonal residual of the Mercer proof, so the diagonal Dini step of Theorem 2 makes it tend to zero uniformly in as .
The expansion Equation (5) separates randomness from time. The eigenfunctions are deterministic shapes, the modes of the process, and all the randomness lives in the scalar coefficients , which are uncorrelated and weighted by . A process that was a point in an infinite-dimensional space is now a sequence of independent dials, each turning one mode.
#Optimality of the eigenbasis
The eigenbasis is not one good basis among many. It is the best basis for representing the process in finitely many terms.
Among all orthonormal bases of , the eigenbasis minimises the mean-square error of every finite truncation. For each the minimum truncation error is
attained by .
For any orthonormal basis write . Since by mean-square continuity, almost surely, so Parseval holds pathwise, a.s. Taking expectations and using Tonelli on the nonnegative terms gives the truncation error , since , the swap of expectation and the infinite sum legitimate by monotone convergence. The total is finite by Equation (4) and independent of the basis, since is trace class, so minimising the tail is the same as maximising the head over orthonormal sets of size . By the Ky Fan maximum principle for a positive compact self-adjoint operator, the sum of Rayleigh quotients over an orthonormal set is largest when the set spans the top eigenvectors, with maximum . The complementary minimum tail is , attained at , which is Equation (9).
This is the function-space statement of principal component analysis. The eigenvalues, sorted downward, are the variance captured by each mode, and truncating after terms keeps the most variance any -dimensional linear representation can keep. A process whose eigenvalues decay fast is nearly finite-dimensional, and the decay rate is the precise sense in which a random function is simple or complex.
#The Gaussian case
When the process is Gaussian the coefficients gain their strongest property.
If is a centered Gaussian process then the coefficients of Equation (5) are independent standard normal random variables.
Each is the mean-square limit of Riemann-sum linear functionals . These form a Cauchy net in , because as the meshes shrink (Riemann sums of the continuous deterministic double integral converge), so ; completeness of then yields the limit , the standard mean-square Riemann integral. Finite linear combinations of the values of a Gaussian process are Gaussian, and a mean-square limit of Gaussian vectors is Gaussian, so any finite collection of the is jointly Gaussian and centered. For jointly Gaussian variables zero correlation is independence, and Equation (6) gives , so the are independent standard normals.
For a Gaussian process the expansion is therefore a genuine series of independent standard normals scaled by against fixed shapes, which is why simulating such a process reduces to drawing independent normals and summing modes, the basis of spectral simulation and of the polynomial chaos representations of random fields [4].
#Brownian motion
Take standard Brownian motion on , whose covariance is . The eigenvalue problem becomes a differential equation when differentiated. Splitting the integral at and differentiating once gives , and differentiating again gives
with boundary conditions from the original equation at and from the once-differentiated equation at . The solutions are with , giving the spectral data
and the Karhunen-Loeve expansion of Brownian motion,
The eigenvalues decay as , so the low modes dominate, and the first few carry most of the variance.
| Mode | Share of total variance | |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
The total variance is by the trace identity Equation (4), and the first mode alone holds of it, so four modes already capture about of the variance of a Brownian path.
#Brownian bridge
The Brownian bridge on has covariance , which vanishes at both ends. The same differentiation gives now with , the Dirichlet conditions the pinned endpoints impose, so
The bridge is the pure Fourier sine series of Brownian motion with both ends clamped, and its total variance is , matching . The two processes differ in their boundary conditions alone, half-integer frequencies and a free right end for the motion, integer frequencies and two clamped ends for the bridge.
The three representations sit side by side.
| Basis | Coordinates | Optimal truncation | Coefficients |
|---|---|---|---|
| Fourier | Fixed sines and cosines | No, in general | Correlated, in general |
| Discrete PCA | Eigenvectors of a covariance matrix | Yes, for vectors | Uncorrelated |
| Karhunen-Loeve | Eigenfunctions of | Yes, for processes | Uncorrelated, unit variance |
For Brownian motion and the bridge the Fourier and Karhunen-Loeve bases coincide because the covariance commutes with the second-derivative operator, which is special. For a general process the eigenfunctions are not sinusoids and the Karhunen-Loeve basis is the only one that is both uncorrelated and optimal.
#Numerical illustration
Truncating Equation (12) at a finite order draws a Brownian path from a handful of independent normals, and the optimality result says no other linear basis of the same order reproduces the covariance more faithfully.
import numpy as np
from numpy.random import Generator
def brownian_via_kl(
n_modes: int, grid: np.ndarray, rng: Generator
) -> np.ndarray:
"""Sample a Brownian path on [0, 1] from a truncated Karhunen-Loeve series.
Args:
n_modes: Number of eigenmodes retained in the truncation.
grid: Increasing times in [0, 1] at which to evaluate the path.
rng: Seeded generator for reproducibility.
Returns:
The sampled path values at the grid times.
"""
n = np.arange(1, n_modes + 1)
eigen_root = np.sqrt(2.0) / ((n - 0.5) * np.pi)
modes = np.sin(np.outer(grid, (n - 0.5) * np.pi))
coefficients = rng.standard_normal(n_modes)
return modes @ (eigen_root * coefficients)
def captured_variance(n_modes: int) -> float:
"""Fraction of total Brownian variance held by the first modes.
Args:
n_modes: Number of leading eigenmodes.
Returns:
The ratio of retained eigenvalue mass to the total one half.
"""
n = np.arange(1, n_modes + 1)
eigenvalues = 1.0 / ((n - 0.5) * np.pi) ** 2
return float(eigenvalues.sum() / 0.5)
rng = np.random.default_rng(0)
grid = np.linspace(0.0, 1.0, 500)
path = brownian_via_kl(n_modes=8, grid=grid, rng=rng)
retained = captured_variance(n_modes=8)
A stochastic process is a random function, and the Karhunen-Loeve expansion is its coordinate system. The covariance operator supplies the axes, Mercer's theorem reconstructs the process from them, the expansion turns the random function into uncorrelated dials, and the optimality theorem proves those axes are the ones that compress it best. Brownian motion is a weighted sine series with random amplitudes, and the same construction handles any second-order process, which is why the expansion is the spectral foundation of simulation, of dimensionality reduction for random fields, and of the principal component analysis of functional data.