2025 Week4 - Interpolation and curve fitting
Overview
The lecture distinguishes interpolation, which passes through every data point, from curve fitting, which minimizes a chosen error measure, then compares polynomial interpolation, cubic splines, and radial basis functions (RBFs). It connects these methods to linear systems and least squares, explaining Runge oscillations, ill-conditioning, the pseudoinverse, and how weights and RBF parameters affect results.
Key takeaways
- Interpolation assumes exact observations and passes through every point, while curve fitting usually minimizes a residual norm and can ignore individual noisy measurements.
- High-degree global polynomial interpolation can exhibit Runge oscillations and severe Vandermonde ill-conditioning, so low-degree models or cubic splines are often safer.
- Barycentric Lagrange interpolation reduces evaluation to roughly O(n) after setup and allows x-dependent weights to be reused when only y-values change.
- Cubic splines use local degree-three pieces joined with derivative continuity, producing a sparse tridiagonal system rather than one global high-degree polynomial.
- RBF predictions depend on distance-based kernels and hyperparameters such as Gaussian width; poor choices can create ill-conditioned systems and misleading artifacts.
- Weighted least squares changes the objective by assigning different importance to observations; inverse-variance weights favor measurements with lower uncertainty.
Chapters
- Interpolation assumes measured points are exact and constructs a curve that passes through each one.
- Curve fitting seeks a best fit, often by minimizing the sum of squared residuals, but the choice of vector norm determines what “best” means.
- Interpolation commonly captures local behavior, while curve fitting aims to summarize the broader trend despite measurement noise.
- A polynomial can pass through n data points using at most degree n minus 1, but high-degree polynomials can be cumbersome to evaluate.
- A line may be a more useful curve fit than a high-degree interpolant when measurements contain noise.
- Model construction speed, the cost of adding data, evaluation speed, and generalizability are practical considerations.
- A sampled Gaussian illustrates the recovery problem: infer an underlying curve from discrete points without knowing the original function.
- Evenly spaced versus unevenly spaced x-coordinates can substantially affect numerical behavior.
- Three polynomial construction methods are introduced, all producing the same unique interpolating polynomial for a given set of distinct x-values.
- Lagrange interpolation writes the overall function as a weighted sum of basis polynomials, with measured y-values as the weights.
- Each basis polynomial is 1 at its associated x-coordinate and 0 at every other data coordinate.
- For the example points (0, 1), (0.5, 3), and (2, 2), the three basis functions combine into a quadratic interpolant.
- Because only one Lagrange basis function is nonzero at each data coordinate, its coefficient is simply that point’s measured y-value.
- Direct evaluation across n basis polynomials costs roughly O(n²), and adding a data point requires rebuilding the polynomial.
- Repeated x-coordinates make the basis denominators zero, so ordinary Lagrange interpolation requires distinct x-values.
- The interpolation error depends on a product of distances from the evaluation point to the data coordinates and on a derivative of the underlying function.
- A distant data point can strongly affect error, which conflicts with the intuition that nearby observations should dominate a local estimate.
- The limitation belongs to high-degree polynomial interpolation generally, not just the Lagrange construction.
- Barycentric weights precompute products determined by the x-coordinates, avoiding repeated calculation of the same factors.
- The reformulated evaluation reduces the cost from roughly O(n²) to O(n) after setup.
- The x-dependent weights can be reused if the same sampling locations are paired with new y-values; the barycentric form also helps avoid some numerical issues near data points.
- Newton divided differences provide another construction of the same unique interpolating polynomial.
- Their recursive structure allows new data points to be incorporated without recomputing every previous term.
- The Difference Engine associated with Charles Babbage was designed to automate difference calculations for tables and similar numerical tasks.
- Writing a polynomial as a weighted sum of monomials converts interpolation into a linear system for its coefficients.
- The coefficient matrix is the Vandermonde matrix, whose rows contain powers of each x-coordinate.
- Solving the system directly is convenient for small examples, but Vandermonde matrices are often severely ill-conditioned.
- An 11th-degree interpolant of evenly spaced samples can oscillate despite passing through every point.
- Runge phenomenon describes large, high-frequency oscillations that can arise with high-degree polynomial interpolation, especially near interval boundaries.
- The practical rule is to avoid unnecessarily high-degree global polynomials and consider piecewise methods instead.
- A cubic spline fits a separate degree-three polynomial between each neighboring pair of data points.
- The pieces meet at the data points with C0 continuity, and continuity of the first and second derivatives gives C1 and C2 smoothness.
- Four constraints determine a cubic segment, while derivative continuity links adjacent segments and helps suppress high-degree oscillations.
- The illustrated spline formulation uses knot values related to the curve’s second derivatives and leads to a linear system.
- That system is tridiagonal and sparse, making sparse linear solvers a natural choice.
- Boundary behavior needs an additional convention, such as periodic conditions or a zero-slope endpoint; spline packages provide standard options.
- Nearest-neighbor interpolation extends to n dimensions by selecting the closest sample, but requires a search for that neighbor.
- Piecewise linear interpolation uses nearby points and can create faceted surfaces, like polygonal graphics viewed at close range.
- Using more points for smoother local behavior increases coupling and can turn the computation into a larger linear-system problem.
- An RBF depends on the distance between an evaluation point and a data point, so its shape is radial in multiple dimensions.
- The interpolant is a weighted sum of one kernel centered at each sample location.
- A Gaussian kernel is a common choice, and the weights are found by matching the interpolant to the measured y-values at the sample locations.
- Kernels that decay with distance make nearby observations contribute more strongly than distant ones.
- For a Gaussian RBF, the width or epsilon is a hyperparameter controlling how far each data point’s influence spreads.
- Choosing a width based on average point spacing is a possible starting heuristic, not a guarantee of a good fit.
- Gaussian kernels approach zero but do not become exactly zero, so the RBF interpolation matrix is generally dense.
- Compact-support kernels can produce sparse matrices because distant points have exactly zero influence.
- Poor epsilon choices can make the interpolation matrix ill-conditioned and produce large artifacts; sums of Gaussian kernels are infinitely differentiable.
- Curve fitting may use many observations but only a few model parameters, unlike interpolation, which forces a match at every point.
- The residual vector records prediction minus observation, and a common objective is to minimize its Euclidean norm.
- The pseudoinverse extends linear-system methods to rectangular matrices, enabling least-squares fitting without an iterative optimization routine.
- For a system Ax = b, least squares minimizes the squared residual norm ||Ax - b||².
- For a full-column-rank overdetermined system, the normal-equation solution uses (AᵀA)⁻¹Aᵀb.
- Practical pseudoinverse implementations typically use singular value decomposition rather than explicitly forming the normal equations; NumPy also provides least-squares routines.
- An inconsistent overdetermined system has more equations than unknowns and usually no exact solution; least squares returns the parameters minimizing residual error.
- For an underdetermined system, the pseudoinverse can return a solution, usually the one with minimum parameter norm, but that is not the only solution.
- The minimum-norm result can be misleading if interpreted as a uniquely determined physical answer.
- The pseudoinverse is defined for rectangular matrices and can also handle square matrices, though its computation may be more involved than a direct inverse.
- A tables-and-chairs example uses a rectangular system to find a least-squares solution; NumPy offers pseudoinverse and least-squares interfaces.
- Geometrically, least squares minimizes perpendicular residual distances to the equations, not simply the distances between their intersection points.
- Weights change how strongly each equation or observation contributes to the residual objective.
- Scaling equations can move the least-squares solution, even when the equations’ exact solution set would be unchanged in a consistent system.
- For repeated measurements, inverse variance weighting gives more influence to measurements with lower estimated uncertainty.
- A Vandermonde matrix lets least squares fit a low-degree polynomial, such as a quadratic, to many noisy observations.
- Increasing polynomial degree can reduce training residuals, but a lower residual alone does not establish that the model generalizes well.
- A residual norm that levels off near the known generating degree can help guide model selection, while high-degree Vandermonde matrices become increasingly ill-conditioned.
- Modern RBF interpolation can combine a low-degree polynomial trend with radial basis terms, solving for the components simultaneously.
- SciPy’s RBF interpolator exposes a polynomial degree and a smoothing parameter, commonly denoted lambda.
- Smoothing trades exact passage through noisy observations for a smoother curve or surface; check package documentation because APIs and parameter conventions can vary.
- The lecture’s methods differ in their tradeoffs: global polynomials can oscillate, cubic splines use local cubic pieces, and RBFs offer flexible distance-based models.
- The SciPy RBF example reconstructs a sampled Gaussian reasonably well, while boundary behavior depends on both the data and the model setup.
- Numerical results require judgment about conditioning, model degree, kernel choice, and smoothing rather than assuming every computed fit is trustworthy.
Transcript excerpt
0:00 office hours whenever you want. Uh let's see. So today we're going to start talking about interpolation and curve fitting. Um this is going to be another kind of funny one. Interpolation is pretty straightforward. Curve fitting technically brings us into optimization which doesn't actually get covered until two weeks from now. Um, so this is one of those things that like we we we're going to start off on one side, but we need to get that side because a lot of the optimization routines use interpolation algorithms, but we need the optimization in order to get to the curve fitting one. And it's just kind of it's it's ultimately this sort of thing is like a nonlinear path and we're just going to have to do the best that we can to go sequentially through it because otherwise it gets too mixed up in our
0:46 heads and things. So, uh, bear with me through that one. Um it it just means that we're going to jump ahead and back and forth a little bit with optimization, but that won't be until uh uh Thursday. We'll get into the optimization part. Um we're going to cover one thing that uh that I'm actually just going to skip over entirely to try and make space to do um neural nets under the curve finning because everybody is hot to trot about neural nets and everything like that. So I thought it would be interesting to kind of put it in here and teach you guys a little bit about like how that sort of thing works. Okay. So, differences between interpolation and curve fitting. Interpolation fits seeks a curve that goes through all the points in a plot, right? That's that's kind of what you're doing when you're like fitting a curve,
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Numerical Methods for Engineering.