1 / 20

Fish 507; Lecture 23

Interpolation Methods. Fish 507; Lecture 23. What is Interpolation?. There is a function f( x ) that is very “expensive” (or difficult) to evaluate. We wish to compute f( x ) for many values of x as “cheaply” as possible.

jaden
Download Presentation

Fish 507; Lecture 23

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Interpolation Methods Fish 507; Lecture 23

  2. What is Interpolation? • There is a function f(x) that is very “expensive” (or difficult) to evaluate. We wish to compute f(x) for many values of x as “cheaply” as possible. • We have data points (x,y=g(x)) but do not know the function g. We wish to compute g(x) for values of x other than those for which the data points are available.

  3. Consider the “Runge” Function Given these seven data points, how do we determine the values of y for other values for x?

  4. Linear Interpolation-I • Approximate f(x) between xi and xi+1 by a straight line connecting xi and xi+1, i.e.: or

  5. Linear Interpolation-II Linear interpolation is very accurate in this case, but it requires knowing between which values of xi the x we are interested in lies

  6. Linear Interpolation-III • R includes the function approx which can be used to perform linear interpolation: approx(x, y, xout) • x,y – the vector of (x,y) pairs on which to base the calculations. • xout – a vector of values of x for which values of f(x) are required.

  7. Polynomial Interpolation-I • There are many ways to approximate a function using a polynomial. The simplest is to approximate the function by: • Note that: • this approximation is exact for x=x1, x2, x3, etc.; and • a single equation is used to approximate the entire function.

  8. Polynomial Interpolation-II The polynomial passes though all seven points but….

  9. Polynomial Interpolation-III A better approximation can be obtained in this case by applying polynomial interpolation with N=3 (i.e. quadratic functions)

  10. Rational Interpolation-I • Rather than approximating a function by a simple polynomial, we can approximate it by the ratio of polynomials, i.e.: • This approach can deal with poles in the function to be approximated (unfortunately even when they are not there).

  11. Rational Interpolation-II Rational approximation performs better than simple polynomial interpolation for the Runge function (as expected?)

  12. More Examples

  13. Splines-I • Cubic splines are piecewise cubic polynomials that approximate a function such that: • The zeroth, first and second derivatives are continuous; • the approximating function matches the points on which it is based; and • the second derivatives of the approximating function match the second derivatives of the function.

  14. Splines II • Define a set of points (called “knots”) – these are the points for which data are available: • The cubic spline is defined by the equation: • This equation has four parameters for each pair of knots. The values for these parameters are defined from the function values at the knots and the (numerical) second derivatives at the knots.

  15. Splines III The cubic spline is able to satisfactorily mimic the underlying shape almost perfectly y3 <- spline(x,y) lines(y3,col=19,lwd=3)

  16. Splines -IV • Using a Spline for interpolation requires that the values for the parameters be computed. • In order to predict the value of y for some x, it is necessary to apply a search algorithm (e.g. bisection) to find the knots between which x lies.

  17. Splines V • R includes the function spline: spline(x, y, n, periodic, xmin, xmax ) • Arguments: • x, y – the data (required); • n – number of output points; • periodic – is the function periodic? • xmin / xmax – range to predict over. • Output: • List with components x and y that provide the results of the cubic spline fitting.

  18. Splines VI Spline vs linear interpolation based on 8, 12 and 16 points

  19. Interpolation and Extrapolation-I • Polynomial and rational approximation are methods for interpolation. In principle, they can be used to extrapolate beyond the range of the xs for which data are available. This should, however, be done with considerable caution. • Consider the following selectivity ogive.

  20. Interpolation and Extrapolation-II 3-point polynomial interpolation. Extrapolation beyond age=0 and age=25 is based on the results for the first and last intervals

More Related