Why Projection Separates Two Sources of Error
A series density estimator represents a density using a finite collection of orthonormal functions. Keeping more functions can represent more features of the target density, but it also means estimating more coefficients from the sample. Orthogonal projection makes these two effects precise: the part of the density outside the chosen span is approximation error, while the estimated coefficients introduce sampling variation.
The distinction is useful because it gives an exact integrated squared error identity before any asymptotic approximation. It also shows what controls the total variance: the number of included terms, the density, and the size of the basis functions over the domain.
Projection and the Series Estimator
Let \(D\) be a measurable subset of the real line, and let \(f\) be a probability density on \(D\) with \(\int_D f(x)^2\,dx<\infty\). Suppose \(X_1,\ldots,X_n\) are independent observations with density \(f\). Choose \(m\) functions \(\phi_1,\ldots,\phi_m\) that are orthonormal in \(L^2(D)\), meaning that \(\int_D \phi_j(x)\phi_k(x)\,dx\) equals 1 if \(j=k\) and 0 otherwise.
Each estimated coefficient is unbiased: \(E[\hat{\theta}_j]=\theta_j\), provided \(E[\phi_j(X_1)^2]<\infty\). The projection \(f_m\) is the best approximation to \(f\) in the chosen span under integrated squared error: its residual \(f-f_m\) is orthogonal to every function in that span. The result below uses this orthogonality to separate errors exactly.
Exact Integrated Squared Error Decomposition
Here \(\|g\|_2^2=\int_D g(x)^2\,dx\). The first identity holds for the realized estimator, not just on average. To prove it, write \(\hat{f}_m-f=(f_m-f)+(\hat{f}_m-f_m)\). The second term belongs to the span of the basis. The first is orthogonal to that span, so their integrated product is zero. Orthonormality also gives \(\|\hat{f}_m-f_m\|_2^2=\sum_{j=1}^m(\hat{\theta}_j-\theta_j)^2\). Expanding the squared norm therefore yields the first identity.
For the expected identity, take expectations of both sides. Unbiasedness gives \(E[(\hat{\theta}_j-\theta_j)^2]=\operatorname{Var}(\hat{\theta}_j)\). Since the observations are independent and identically distributed, \(\operatorname{Var}(\hat{\theta}_j)=\operatorname{Var}(\phi_j(X_1))/n\). Substitution proves the claim. \(\square\)
The first term, \(\|f-f_m\|_2^2\), is the squared projection error, sometimes called the squared approximation bias. The second is the sum of the coefficient estimation variances. No covariance terms appear in this integrated error: orthonormality makes distinct basis functions contribute separate squared coefficient errors. This does not mean the estimated coefficients are necessarily independent.
Worked Example: A Fourier Density With One Nonzero Frequency
On \(D=[0,1]\), consider \(f(x)=1+\frac12\cos(2\pi x)\), which is a density because it integrates to 1 and is at least \(1/2\). Use the first two functions \(\phi_1(x)=1\) and \(\phi_2(x)=\sqrt{2}\cos(2\pi x)\). They are orthonormal on this interval.
The coefficients are \(\theta_1=\int_0^1 f(x)\,dx=1\) and \(\theta_2=\int_0^1\phi_2(x)f(x)\,dx=1/(2\sqrt{2})\). Thus with \(m=2\), \(f_2=f\) and the projection error is zero. With \(m=1\), \(f_1=1\), so the projection error is \(\int_0^1 [\frac12\cos(2\pi x)]^2\,dx=\frac14\cdot\frac12=\frac18\).
For \(m=2\), the constant coefficient has zero variance because \(\phi_1(X_i)=1\). For the second coefficient, \(E[\phi_2(X_1)^2]=\int_0^1 2\cos^2(2\pi x)(1+\frac12\cos(2\pi x))\,dx=1\). The term involving \(\cos^3(2\pi x)\) integrates to zero. Therefore \(\operatorname{Var}(\phi_2(X_1))=1-\theta_2^2=1-\frac18=\frac78\), and the integrated risk at \(m=2\) is \(7/(8n)\). The comparison is exact: at \(m=1\) the estimator has risk \(1/8\) and no sampling variance; at \(m=2\) it has no projection error but risk \(7/(8n)\) from estimating the added coefficient.
Bounding the Total Variance
The exact formula reduces the variance calculation to the second moments of the basis functions under the sampling density. A useful bound follows when the density is bounded. More generally, the same argument applies when the combined squared size of the basis functions is bounded.
To prove the bounded-density bound, use \(\operatorname{Var}(\phi_j(X_1))\leq E[\phi_j(X_1)^2]\) and sum: \(\sum_{j=1}^m E[\phi_j(X_1)^2]=\int_D f(x)\sum_{j=1}^m\phi_j(x)^2\,dx\). Since \(f(x)\leq\|f\|_\infty\) almost everywhere and the functions are orthonormal, \(\int_D\sum_{j=1}^m\phi_j(x)^2\,dx=m\). The sum of second moments is therefore at most \(m\|f\|_\infty\), and division by \(n\) proves the result. For the more general bound, the displayed integral is at most \(B_m\int_D f(x)\,dx=B_m\), because \(f\) integrates to 1. Again divide by \(n\). \(\square\)
A pointwise bound on each individual basis function can yield a looser estimate than bounding their combined squared magnitude. For a Fourier basis made of complete sine-cosine pairs, the sum of squared basis functions is constant in \(x\), so the combined bound can be particularly direct. In other settings, it may be useful to retain the exact variance formula rather than replace it with an upper bound.
Worked Example: A Uniform Density and Five Fourier Terms
Let \(X_i\) be uniform on \([0,1]\), so \(f(x)=1\). Take \(m=5\) orthonormal functions: \(1\), \(\sqrt{2}\cos(2\pi x)\), \(\sqrt{2}\sin(2\pi x)\), \(\sqrt{2}\cos(4\pi x)\), and \(\sqrt{2}\sin(4\pi x)\). The density is already in their span, so the projection error is zero.
The coefficient of the constant function is 1, with variance zero. Each of the other four coefficients has mean zero and second moment 1 under the uniform distribution, so each has variance 1. Consequently the integrated variance is \(4/n\), and the integrated risk is exactly \(4/n\).
The bounded-density result gives the upper bound \(m\|f\|_\infty/n=5/n\). It is valid but not exact: it bounds all five second moments by \(1\), whereas the constant coefficient is known without sampling error. This illustrates why the exact variance formula can be informative even when a simple dimension-based bound is available.
Worked Example: Projection Bias and Variance for a Piecewise-Constant Series
On \([0,1]\), let \(f(x)=\frac23(1+x)\). This is a density because \(\int_0^1\frac23(1+x)\,dx=1\). Divide the interval into \(I_1=[0,\frac12)\) and \(I_2=[\frac12,1]\), and use \(\phi_j(x)=\sqrt{2}\,\mathbf{1}_{I_j}(x)\), for \(j=1,2\). These two functions are orthonormal.
The probabilities of the two intervals are \(p_1=\int_0^{1/2}f(x)\,dx=5/12\) and \(p_2=7/12\). The coefficients are \(\theta_1=\sqrt{2}p_1\) and \(\theta_2=\sqrt{2}p_2\). On each interval, the projection \(f_2\) is the average density there: it is \(5/6\) on the first interval and \(7/6\) on the second.
The slope of \(f\) is \(2/3\). On an interval of width \(h=1/2\), the integrated squared difference from the interval average is \((2/3)^2\int_{-h/2}^{h/2}u^2\,du=(4/9)h^3/12=1/216\). There are two intervals, so the projection error is \(1/108\).
For each coefficient, \(E[\phi_j(X_1)^2]=2p_j\), and \(\theta_j^2=2p_j^2\). Summing the coefficient variances gives \(\sum_{j=1}^2\operatorname{Var}(\phi_j(X_1))=2(p_1+p_2)-2(p_1^2+p_2^2)=2-2(25/144+49/144)=35/36\). Thus the total integrated risk is \(1/108+35/(36n)\). The two terms quantify distinct errors: the projection cannot reproduce the within-interval slope, while the sample coefficients fluctuate around their projection values.
What the Decomposition Tells Us
The identity applies for each fixed choice of the basis and its dimension \(m\). It does not by itself prescribe how to choose those functions or how many to include. It does establish the quantities that such a choice must balance: approximation error from projecting the density and variance from estimating the coefficients. The variance bound shows why a larger series can incur a larger sampling contribution, with a typical upper bound proportional to \(m/n\) when the density is bounded.
In applications, the exact decomposition is useful for checking derivations and for comparing candidate series spaces. The approximation term depends on how well the selected span represents the target density; the variance term depends on how the observations populate the basis functions. Both matter for integrated squared error, and neither can be inferred from the number of terms alone.
Common Mistake
A frequent error is to claim that the coefficient estimates are independent because the basis functions are orthogonal. Orthogonality is an integral statement with respect to the reference measure \(dx\); coefficient dependence is governed by expectations under the sampling density \(f\). In general, \(\operatorname{Cov}(\phi_j(X_1),\phi_k(X_1))\) need not be zero. The integrated error formula has no covariance terms for a different reason: the squared \(L^2\) norm of a sum of orthogonal functions is the sum of their squared coefficients. Do not use orthogonality to assert independence or to discard covariance in a pointwise variance calculation.
Check Your Understanding
Try these questions using the definitions and identities above.
- Why does the realized integrated squared error have no cross-product term between \(f-f_m\) and \(\hat{f}_m-f_m\)?
- For a coefficient estimate based on \(n\) independent observations, how does its variance relate to the variance of one basis-function evaluation?
- What condition on the density yields the upper bound \(m\|f\|_\infty/n\), and where does orthonormality enter its proof?
- In the five-term Fourier example, why is the exact variance \(4/n\) rather than \(5/n\)?
- Explain why orthogonality of the basis does not imply that the estimated coefficients are independent.