After two blog posts earlier this year on Chebyshev and Jacobi polynomials, I am coming back to orthogonal polynomials, with Hermite polynomials.
This time, in terms of applications to machine learning, no acceleration, but some interesting closed-form expansions in positive-definite kernel methods.
Definition and first properties
There are many equivalent ways to define Hermite polynomials. A natural one is through the so-called Rodrigues’ formula:
Hk(x)=(−1)kex2dxkdk[e−x2],
from which we can deduce H0(x)=1, H1(x)=–ex2[−2xe−x2]=2x, H2(x)=ex2[(−2x)2e−x2−2e−x2]=4x2–2, etc.
Other simple properties which are consequences of the definition (and can be shown by recursion) are that Hk is a polynomial of degree k, with the same parity as k, and with a leading coefficient equal to 2k.
Orthogonality for Gaussian distribution. Using integration by parts, one can show (see end of the post) that for k=ℓ, we have
∫−∞+∞Hk(x)Hℓ(x)e−x2dx=0,
and that for k=ℓ, we have
∫−∞+∞Hk(x)2e−x2dx=π2kk!.
In other words, the Hermite polynomials are orthogonal for the Gaussian distribution with mean 0 and variance 21. Yet in other words, defining the Hermite functions as ψk(x)=(π2kk!)−1/2Hk(x)e−x2/2, we obtain an orthonormal basis of L2(dx). As illustrated below, the Hermite functions, as the index k increases, have an increasing “support” (the support is always the entire real line, but most of the mass is concentrated in centered balls of increasing sizes, essentially at k) and, like cosines and sines, an increasingly oscillatory behavior.
Plot of Hermite functions ψk(x)=(π2kk!)−1/2Hk(x)e−x2/2, from k=0 to k=20.
Among such orthonormal bases, the Hermite functions happen to be diagonalizing the Fourier tranform operator. In other words, the Fourier transform of ψk (for the definition making it an isometry of L2(dx)) is equal to
F(ψk)(ω)=2π1∫−∞+∞ψk(x)e−iωxdx=(−i)kψk(ω).
(note that the eigenvalues are all of unit modulus as we have an isometry). See a proof at the end of the post. I am not aware of any applications of this property in machine learning or statistics (but there are probably some).
Recurrence. In order to compute Hermite polynomials, the following recurrence relation is the most useful
Hk+1(x)=2xHk(x)–2kHk−1(x).(1)
Such recursions are always available for orthogonal polynomials (see [4]), but it takes here a particularly simple form (see a proof at the end of the post).
Generating function. The following property is central in many proofs of properties of Hermite polynomials: for all t∈R, we have
k=0∑∞k!tkHk(x)=e2xt–t2,(2)
with a proof at the end of the post based on the residue theorem.
Further (less standard) properties
For the later developments, we need other properties which are less standard (there are many other interesting properties, which are not useful for this post, see here).
The proof is significantly more involved; see [1] for details (with a great last sentence: “Prof. Hardy tells me that he has not seen his proof in print, though the inevitability of the successive steps makes him think that it is unlikely to be new”). Note that we will in fact obtain a new proof from the relationship with kernel methods (see below).
Expectation for Gaussian distributions. We will need this property for ∣ρ∣<1 (see proof at the end of the post), which corresponds to the expectation of Hk(x) for x distributed as a non-centered Gaussian distribution:
Given the relationship with the Gaussian distribution, it is no surprise that Hermite polynomials pop up whenever Gaussians are used, as distributions or kernels. Before looking into it, let’s first give a brief review of kernel methods.
From positive-definite kernel to Hilbert spaces
Given a prediction problem with inputs in a set X, a traditional way of parameterizing real-valued functions on X is to use positive-definite kernels.
A positive-definite kernel is a function K:X×X→R such that for all sets {x1,…,xn} of n elements of X, the “kernel matrix” in Rn×n composed of pairwise evaluations is symmetric positive semi-definite. This property happens to be equivalent to the existence of a Hilbert feature space H and a feature map φ:X→H such that
This allows to define the space of linear functions on the features, that is, functions of the form
f(x)=⟨f,φ(x)⟩H,
for f∈H.
This space is often called the reproducing kernel Hilbert space (RKHS) associated to the kernel K (we can prove that it is indeed uniquely defined). In such a space, we can also define the squared norm of the function f, namely ∥f∥H2, which can be seen as a specific regularization term in kernel methods.
The space satisfies the so-called reproducing property (hence its name): f(x)=⟨f,K(⋅,x)⟩H. In other words, the feature φ(x) is the kernel function evaluated at x, that is, φ(x)=K(⋅,x). These spaces have been a source of many developments in statistics [5] and machine learning [6, 7].
Orthonormal basis. A difficulty in working with infinite-dimensional Hilbert spaces of functions is that it is sometimes hard to understand what functions are actually considered. One simple way to enhance understanding of the regularization property is to have an orthonormal basis (in very much the same way as the Fourier basis), as we can then identify H to the space of squared-integrable sequences.
For kernel-based Hilbert spaces, if we have an orthonormal basis (gk)k⩾0 of the Hilbert space H, then, by decomposing φ(x) in the basis, we have
that is, we have an expansion of the kernel as an infinite sum (note here, that we ignore summability issues).
Among orthonormal bases, some are more interesting than others. The ones composed of eigenfunctions for particular operators are really more interesting, in particular for the covariance operator that we now present, and their use in statistical learning theory.
Analyzing ridge regression through covariance operators
The most classical problem where regularization by RKHS norms occurs is ridge regression, where, given some observations (x1,y1),…,(xn,yn)∈X×R, one minimizes with respect to f∈H:
n1i=1∑n(yi–⟨f,φ(xi)⟩H)2+λ∥f∥H2.
In finite dimensions, the convergence properties are characterized by the (non-centered) covariance matrix Σ=E[φ(x)⊗φ(x)], where the expectation is taken with respect to the underlying distribution of the observations x1,…,xn (which are assumed independently and identically distributed for simplicity). If H=Rd, then Σ is a d×d matrix.
For infinite-dimensional H, the same expression Σ=E[φ(x)⊗φ(x)] defines a linear operator from H to H, so that for f,g∈H, we have
⟨f,Σg⟩H=E[⟨f,φ(x)⟩H⟨g,φ(x)⟩H]=E[f(x)g(x)].
The generalization property of ridge regression has been thoroughly studied (see, e.g., [8, 9]), and if there exists f∗∈H such that yi=⟨f∗,φ(xi)⟩+εi for a noise εi which is independent of xi, with zero mean and variance equal to σ2, then the expected error on unseen data is asymptotically upper-bounded by
σ2+λ∥f∗∥H2+nσ2tr[Σ(Σ+λI)−1].
The first term σ2 is the best possible expected performance, the term λ∥f∗∥H2 is usually referred to as the bias term and characterizes the bias introduced by regularizing towards zero, while the third term nσ2tr[Σ(Σ+λI)−1] is the variance term, which characterizes the loss in performance due to the observation of only n observations.
The quantity df(λ)=tr[Σ(Σ+λI)−1] is often referred to as the degrees of freedom [10]. When λ tends to infinity, then df(λ) tends to zero; when λ tends to zero, then df(λ) tends to the number of non-zero eigenvalues of Σ. Thus, in finite dimension, this typically leads to the underlying dimension. Given the usual variance term in σ2nd for ordinary least-squares with d-dimensional features, df(λ) is often seen as an implicit number of parameters for kernel ridge regression.
In infinite dimensions, under mild assumptions, there are infinitely many eigenvalues for Σ, which form a decreasing sequence (λi)i⩾0 that tends to zero (and is summable, with a sum equal to the trace of Σ). The rate of such a decay is key to understanding the generalization capabilities of kernel methods. With the following classical types of decays:
Polynomial decays: If λi⩽(i+1)αC for α>1, then one can upper bound the sum by an integral as
With the change of variable u=λtα/C, we get that df(λ)=O(λ−α). We can then balance bias and variance with λ∼n−α/(α+1) and an excess risk proportional to n−α/(α+1). This type of decay is typical of Sobolev spaces.
Exponential decays: If λi⩽Ce−αi, for some α>0, we have
We can then balance bias and variance with λ∼1/n and an excess risk proportional to (logn)/n, which is very close to the usual parametric (finite-dimensional) rate in O(1/n). We will see an example of this phenomenon for the Gaussian kernel.
In order to analyze the generalization capabilities, we consider a measure dμ on X, and the following (non-centered) covariance operator defined above as
E[φ(x)⊗φ(x)],
which is now an self-adjoint operator from H to H with a finite trace. The traditional empirical estimator Σ^=n1∑i=1nφ(xi)⊗φ(xi), whose eigenvalues are the same as the eigenvalues of 1/n times the n×n kernel matrix of pairwise kernel evaluations (see simulation below).
Characterizing eigenfunctions. If (gk) is the eigenbasis associated to the eigenfunctions of Σ, then it has to be an orthogonal family that span the entire space H and such that Σgk=λkgk. Applying it to φ(y)=K(⋅,y), we get
which implies that the functions also have to be eigenfunctions of the self-adjoint so-called integral operatorT defined on L2(dμ) as Tf(y)=∫XK(x,y)f(y)dμ(y). Below, we will check this property. Note that this other notion of integral operator (defined on L2(dμ) and not in H), which has the same eigenvalues and eigenfunctions, is important to deal with mis-specified models (see [9]). Note that the eigenfunctions gk are orthogonal for both dot-products in L2(dμ) and H, but that the normalization to unit norm differs. If ∥gk∥L2(dμ)=1 for all k⩾0, then we have ∥gk∥H2=λk−1⟨gk,Σgk⟩H=λk−1E[gk(x)2]=λk−1 , and thus, ∥λk1/2gk∥H=1, and we have the kernel expansion from an orthonormal basis of H:
K(x,y)=k=0∑∞λkgk(x)gk(y),
which will lead to a new proof for Mehler formula.
Orthonormal basis for the Gaussian kernel
Hermite polynomials naturally lead to orthonormal basis of some reproducing kernel Hilbert spaces (RKHS). For simplicity, I will focus on one-dimensional problems, but this extends to higher dimension.
Translation-invariant kernels. We consider a function q:R→R which is integrable, with Fourier transform (note the different normalization than before) which is defined for all ω∈R because of the integrability:
q^(ω)=∫Rq(x)e−iωxdx.
We consider the kernel
K(x,y)=q(x−y).
It can be check that as soon as q^(ω)∈R+ for all ω∈R, then the kernel K is positive-definite.
For a translation-invariant kernel, we can write using the inverse Fourier transform formula:
with φω(x)=q^(ω)/(2π)eiωx. Intuitively, for a function f:R→R, with f(x)=2π1∫Rf^(ω)eiωxdω=∫R2πq^(ω)f^(ω)φω(x)dω, which is a “dot-product” between the family (φω(x))ω and (2πq^(ω)f^(ω))ω, the squared norm ∥f∥H2 is equal to the corresponding “squared norm” of (2πq^(ω)f^(ω))ω, and we thus have
where f^ is the Fourier transform of f. While the derivation above is not rigorous, the last expression is.
In this section, I will focus on the Gaussian kernel defined as K(x,y)=q(x−y)=exp(–α(x−y)2), for which q^(ω)=απexp(–4αω2).
Given that q^(ω)1=παexp(4αω2)=παk=0∑∞(4α)kk!ω2k, the penalty ∥f∥H2 is a linear combination of squared L2-norm of ωkf^(ω), which is the squared L2-norm of the k-th derivative of f. Thus, functions in the RKHS are infinitely differentiable, and thus very smooth (this implies that to have the fast rate (logn)/n above, the optimal regression function has to be very smooth).
Orthonormal basis of the RKHS. As seen in Eq. (4), an expansion in an infinite sum is necessary to obtain an orthonormal basis. We have:
Because of Eq. (4), with gk(x)=k!(2α)kxkexp(–αx2), we have a good candidate for an orthonornal basis. Let us check that this is the case. Note that the expansion above alone cannot be used as a proof that (gk) is an orthonormal basis of H.
Given the function fk(x)=xkexp(–αx2), we can compute its Fourier transform as
and thus its inverse Fourier transform is equal to (ix)k times the one of (−1)k(4α)k/2exp(–4αω2), which is thus equal to (−i)k(4α)k/2α/πe−αx2, which leads to the Fourier transform formula above.
We can now compute the RKHS dot products, to show how to obtain the orthonormal basis described in [11]. This leads to
which is equal to zero if k=ℓ, and equal to 2π1απ(4α)−k4απ2kk!=(2α)−kk! if k=ℓ. Thus the sequence (fk) is an orthogonal basis of the RKHS, and the sequence (gk) defined as gk(x)=k!(2α)kfk(x) is an orthonormal basis of the RKHS, from which, using the expansion as in Eq. (4), we recover the expansion:
This expansion can be used to approximate the Gaussian kernel by finite-dimensional explicit feature spaces, by just keeping the first basis elements (see an application to optimal transport in [12], with an improved behavior using an adaptive low-rank approximation through the Nyström method in [13]).
Eigenfunctions for the Gaussian kernels
In order to obtain explicit formulas for the eigenvalues of the covariance operator, we need more than a mere orthonormal basis, namely an eigenbasis.
An orthogonal basis will now be constructed with arguably better properties as it is also an orthonormal basis for both the RKHS and L2(dμ) for a Gaussian measure, that diagonalizes the integral operator associated to this probability measure, as well as the covariance operator.
As seen above, we simply need an orthogonal family (fk)k⩾0, such that given a distribution dμ, (fk)k⩾0 is a family in L2(dμ) such that
∫Rfk(x)K(x,y)dμ(x)=λkfk(y),(5)
for eigenvalues (λk). In the next paragraph, we will do exactly this for the Gaussian kernel K(x,y)=e−α(x−y)2 for α=1−ρ2ρ for some ρ∈(0,1); this particular parameterization in ρ is to make the formulas below not (too) complicated.
With fk(x)=Nk1Hk(x)exp(–1+ρρx2), where Nk=2kk!1+ρ1−ρ, then (fk)k⩾0 is an orthonormal basis for L2(dμ) for dμ the Gaussian distribution with mean zero and variance 211−ρ1+ρ (this is a direct consequence of the orthogonality property of Hermite polynomials).
Moreover, the moment of the Hermite polynomial in Eq. (3) exactly leads to Eq. (5) for the chosen kernel and λk=(1−ρ)ρk. Since the eigenvalues sum to one, and the trace of Σ is equal to one (as a consequence of K(x,x)=1), the family (fk) has to be a basis of H.
From properties of the eigenbasis, since (fk) is an orthonormal eigenbasis of L2(dμ) and the eigenvalues are λk=(1−ρ)ρk, we get:
which is exactly the Mehler formula, and thus we obtain an alternative proof.
We then get an explicit basis and the exponential decay of eigenvalues, which was first outlined by [2]. See an application to the estimation of the Poincaré constant in [14] (probably a topic for another post in a few months).
Experiments. In order to showcase the exact eigenvalues of the expectation Σ (for the correct combination of Gaussian kernel and Gaussian distribution), we compare the eigenvalues with the ones of the empirical covariance operator Σ^, for various values of the number of observations. We see that as n increases, the empirical eigenvalues match the exact ones for higher k.
Eigenvalues of the covariance operator Σ (“expectation”) compared to the ones of the empirical covariance operator Σ^, averaged over 20 replications (“empirical”), for several values of n.
Conclusion
In this post, I only presented applications of Hermite polynomials to the Gaussian kernel, but these polynomials appear in many other areas of applied mathematics, for other types of kernels within machine learning such as dot-product kernels [3], in random matrix theory (see here), in statistics for Edgeworth expansions, and of course for Gauss-Hermite quadrature.
Acknowledgements. I would like to thank Loucas Pillaud-Vivien and Alessandro Rudi for proofreading this blog post and making good clarifying suggestions.
where γ is a contour in the complex plane around x. This leads to, for any t (here, we ignore on purpose the summability issues, for more details, see [4, Section 5.5]):
Using the first-order residue at x+t. This is thus equal to ex2−(t+x)2=e−t2+2tx, which is exactly the generating function statement from Eq. (2).
Orthogonality for Gaussian distribution. We can prove through integration by parts, but there is a nicer proof through the generating function. Indeed, with
which can be computed explicitly using normalization constants of the Gaussian distribution, as πe2uv=π∑k=0∞k!(2uv)k, leading to all desired orthogonality relationships using the uniqueness of all coefficients for factors tkuℓ.
Recurrence relationship. Taking the derivative of the generating function with respect to t, one gets (2x−2t)e2tx−t2=k=0∑∞(k−1)!tk−1Hk(x), which is equal to (using again the generating function) k=0∑∞k!tk2xHk(x)–n=0∑∞k!tk+12Hk(x). By equating the coefficients for all powers of t, this leads to the desired recursion in Eq. (1).
Fourier transform. Again using the generating function, written
e−x2/2+2xt–t2=k=0∑∞k!tke−x2/2Hk(x),
we can take Fourier transforms and use the fact that the Fourier transform of e−x2/2 is itself (for the chosen normalization), and then equate coefficients for all powers of t to conclude (see more details here).
Expectation for Gaussian distributions. We finish the appendix by proving Eq. (3). We consider computing for any t,
k=0∑∞ρkk!tkHk(y)=e2ρty–ρ2t2,
using the generating function from Eq. (2). We then compute