Smoothing splines and penalized functions
Control curvature directly through a Sobolev penalty and distinguish the infinite-dimensional variational problem from a restricted polynomial calculation.
On this page
The question for today
What you’ll understand
- State the cubic smoothing-spline variational problem with its domain.
- Identify its affine penalty nullspace and limiting fits.
- Calculate a restricted penalized fit with a consistent loss normalization.
Kernel bandwidths control smoothness indirectly through neighborhoods. A smoothing spline instead assigns an explicit cost to curvature and chooses the function that balances that cost against observed residuals. Although the optimization starts over an infinite-dimensional function space, its minimizer has a finite natural-cubic-spline representation. The penalty leaves affine functions untouched, which explains the large-penalty limit. Keeping track of whether the residual sum is divided by sample size is essential: the numerical meaning of the tuning parameter changes with that convention.
Optimize a function, not a prespecified low-degree polynomial
Take n≥2 pairwise distinct fixed design points in a bounded interval [a,b], with arbitrary real responses. Minimize mean squared residual plus over the Sobolev space , where the second derivative is weak and square integrable. In one dimension this space has a continuously differentiable representative, so point evaluation is well defined. For lambda strictly positive, the distinct design points identify the affine nullspace and the minimizer is unique.
The variational solution is a natural cubic spline with knots at the distinct observed inputs, not one global cubic. It is piecewise cubic with matching first and second derivatives; natural boundary conditions remove unnecessary bending outside the data range. The finite representation is a theorem about this particular quadratic penalty and function space. Changing the penalty to absolute curvature or imposing inequality constraints can produce a different class of solutions, so the cubic conclusion should not be carried over unchanged.
The penalty has a meaningful nullspace
A function has zero curvature penalty exactly when it is affine, up to the usual Sobolev representative. Increasing lambda therefore suppresses nonlinear components rather than shrinking the entire function toward zero. As lambda tends to infinity, the fitted values approach the least-squares affine fit. As lambda decreases to zero, the positive-lambda solutions approach the natural cubic interpolant at distinct inputs, the minimum-curvature member among interpolating functions. The unpenalized optimization at lambda zero itself has many function-valued minimizers.
In a suitable spline basis, the penalty is a positive semidefinite quadratic form. The coefficient normal equations involve the design Gram matrix plus n lambda times the penalty matrix under the average-loss convention. A full-rank evaluation basis makes this sum invertible for positive lambda. Predictions are linear in the responses only when lambda is treated as fixed. Selecting lambda from the responses makes the overall fitting rule adaptive and generally nonlinear, even though every candidate smoother has a matrix representation.
Effective complexity and uncertainty are different calculations
The trace of the fixed smoothing matrix is often called its effective degrees of freedom. It interpolates between highly flexible fitting and the two affine degrees of freedom, under the standard distinct-input cubic construction. It is not simply the count of basis coefficients, since shrinkage can leave many basis coordinates present with small influence. Leave-one-out cross-validation can exploit the diagonal smoother entries when the candidate smoothing parameter and fitting rule are held fixed for each calculation.
Under independent homoskedastic noise the covariance of fitted values is sigma squared times the smoothing matrix times its transpose. It is generally not sigma squared times the smoothing matrix, because a penalized smoother is not usually an orthogonal projection. Confidence intervals based only on this variance target the smoothed mean unless bias is negligible or separately controlled. A small cross-validation error therefore does not by itself certify a confidence band for the unsmoothed regression curve.
Work it through
A restricted quadratic calculation
On [−1,1] take inputs −1,0,1 with responses 1,0,1. Restrict the candidate functions to f(x)=a x² and use the averaged-residual objective with curvature penalty lambda. Find the optimal a, clearly distinguishing this restricted calculation from a full smoothing spline.
The average residual sum is 2(1−a)²/3. The second derivative is 2a, so the integrated squared curvature on an interval of length two is 8a².
Differentiate 2(1−a)²/3+8lambda a². The normal equation is (4/3)(a−1)+16lambda a=0, giving a=1/(1+12lambda).
At lambda=1/12 the coefficient is one-half; at lambda=1/4 it is one-quarter. Curvature suppression is visible directly, but the full variational solution may also use unpenalized affine terms and piecewise cubics. It is not generally this restricted quadratic.
The restricted coefficient shrinks by 1/(1+12lambda). Its factors depend on both the interval length and the averaged-loss convention.
The living notebook
Explore the model
Interactive lab · function
Compare two restricted penalized fits
Pause and Reset, then set both controls to coefficient a=0.5 and position x=1; predict value 0.5 and slope 1. Reset and set a=0.25 and x=1; predict value 0.25 and slope 0.5. These correspond to the restricted example's two penalty values. The instrument evaluates a quadratic; it does not optimize a smoothing spline or represent its affine nullspace.
- y at chosen x
- 0.608
- Tangent slope · 2ax
- 1.35
- Signed area · ax³/3
- 0.182
This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forPenalizing curvature shrinks nonlinear shape; a restricted example can expose the calculation without replacing the full variational theorem.
Pause & reason
Check your understanding
Your turn
Try it yourself
Use the restricted data and quadratic family from the example, but write the residual sum without dividing by three. Let its penalty coefficient be eta. Derive the minimizing a and the conversion between eta and lambda that gives the same fit.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
The unnormalized objective is 2(1−a)²+8eta a². Alternatively multiply the original complete objective by three.
Compare with the solution
Differentiation gives 4(a−1)+16eta a=0, so a=1/(1+4eta). To match 1/(1+12lambda), set eta=3lambda. Multiplying the averaged objective by three confirms that the entire penalty must also acquire that factor. Comparing numerical penalty values between implementations without checking loss normalization can therefore change the fit even when both use the same curvature integral.
Keep the idea
Take it with you
- A positive curvature penalty over W²,² yields a natural cubic smoothing spline.
- Affine functions form the unpenalized nullspace; lambda zero needs a limiting interpretation.
- Loss normalization, shrinkage covariance and smoothing bias all matter for inference.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.