- By
**jaden** - Follow User

- 294 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about 'Fish 507; Lecture 23' - jaden

**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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

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.
- 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.

Consider the “Runge” Function

Given these seven data points,

how do we determine the

values of y for other values for x?

Linear Interpolation-I

- Approximate f(x) between xi and xi+1 by a straight line connecting xi and xi+1, i.e.:

or

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

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.

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.

Polynomial Interpolation-III

A better approximation can be obtained in this case by applying

polynomial interpolation with N=3 (i.e. quadratic functions)

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).

Rational Interpolation-II

Rational approximation performs better than simple

polynomial interpolation for the Runge function (as expected?)

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.

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.

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)

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.

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.

Splines VI

Spline vs linear interpolation based on 8, 12 and 16 points

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.

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

Download Presentation

Connecting to Server..