This is an archived page, please click here to view the latest updates.

OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

Interpolate Extrapolate Y from X

Image:Video_Image.png See more related video:Origin VT-0010 Interpolation

Contents

Description

Interpolation is a method of estimating and constructing new data points from a discrete set of known data points. Given an X vector, this function interpolates vector Y base on the input curve (XY Range). Origin provides three options for data interpolation: Linear, Cubic spline and Cubic B-spline methods

Linear interpolation is the simplest and fastest data interpolation method. In linear interpolation, the arithmetic mean of two adjacent data points is calculated. This method is useful in situations where low precision can be tolerated. Linear interpolation is also useful for extremely large data sets, because the calculations are not time or computation-power intensive.

The generalization of linear interpolation is polynomial interpolation. Polynomial interpolation requires much more computation power than linear interpolation, and when the polynomial order is high, the fit of the data oscillates wildly. These disadvantages can be avoided by using low-order polynomial fitting, or spline interpolation.

The Cubic spline method uses 3rd order polynomials, and executes data-fitting in a piecewise fashion. spline interpolation incurs less error than linear interpolation, and the interpolant is smoother.

Similar to Cubic spline interpolation, Cubic B-spline interpolation also fits the data in a piecewise fashion, but it uses 3rd order Bezier splines to approximate the data. Cubic B-Splines allow the accurate modeling of more general classes of geometry.

Note: To generate uniform linear spaced interpolated values, use the interp1xy X-Function.

To use this function:

  1. Create a new worksheet with input data.
  2. select desired data.
  3. Select Analysis: Mathematics: Interpolate/Extrapolate Y from X. This opens the interp1 dialog.

In fact, the interp1 X-Function is called to complete the calculation.

Dialog Options

X Values to Interpolate

The vector to interpolate on.

Input

The XY range to be interpolated.

Method

Specify interpolation methods

  • Linear
    Linear interpolation is a fast method of estimating a data point by constructing a line between two neighboring data points. The resulting point may not be an accurate estimation of the missing data.
  • Cubic Spline
    This method splits the input data into a given number of pieces, and fits each segment with a cubic polynomial. The second derivative of each cubic function is set equal to zero. With these boundary conditions met, an entire function can be constructed in a piece-wise manner.
  • Cubic B-Spline
    This method also splits the input data into pieces, each segment is fitted with discrete Bezier splines.
Boundary

Boundary condition is only available in cubic spline method.

Natural
2nd derivatives are 0 on both end.
Not-A-Knot
3rd derivatives are continuous on the second and last-second point.
Smoothing Factor

Smoothing is only available in Cubic B-Spline method.

Result of interpolation

The output vector.

Coefficients

Spline coefficients when using spline or B-spline method.

Algorithm

Given a sequence of distinct pairs of data (x_i\,, y_i\,), where i= 0, 1, ... n-1\!. we are looking for the interpolated y\! at x\! by the following methods:

1. Linear interpolation (interp1q)

For x<x_{0,}y=y_0+\frac{y_1-y_0}{x_1-x_0}\times (x-x_0)

For x>x_{n-1,}y=y_{n-1}+\frac{y_{n-1}-y_{n-2}}{x_{n-1}-x_{n-2}}\times (x-x_{n-1})

For x_i<x<x_{i+1,}y=y_i+\frac{(y_{i+1}-y_{i)}}{(x_{i+1}-x_{i)}}\times (x-x_i)

2. Cubic spline (spline)

Origin uses the natural cubic spline to do interpolation:

y=Ay_i+By_{i+1}+Cy_i^{''}+Dy_{i+1}^{''}

where:

A\equiv \frac{x_{i+1}-x}{x_{i+1}-x_i},B\equiv 1-A,C\equiv \frac 16\left( A^3-A\right) \left( x_{i+1}-x_i\right) ^2,D\equiv \frac 16(B^3-B)(x_{i+1}-x_i)^2

And y_i^{''}can be generated from:

\frac{x_i-x_{i-1}}6y_{i-1}+\frac{x_{i+1}-x_{i-1}}3y_i+\frac{x_{i+1}-x_i}6y_{i+1}=\frac{y_{i+1}-y_i}{x_{i+1}-x_i}-\frac{y_i-y_{i-1}}{x_i-x_{i-1}}

For boundary points, we set y_o^{''} and y_{n-1}^{''}equal to zero.

3. Cubic B-spline (bspline)

For x<x_0\! or x>x_{n-1}\!perform linear interpolation.

For x_0<x<x_{n-1},y=\sum_{i=1}^{n-4} c_iN_i(x)

Here, Failed to parse (Missing texvc executable; please see math/README to configure.): N(x)\!

denotes the normalized cubic B-spline defined upon the knots x_i\,, x_i+1\,, ..., x_i+4\,, And c_i\, denotes the coefficient of the corresponding function.

The total number n\! of these knots and their values x_1\,, ..., x_n\, are chosen automatically by the function. The knots x_5\,, ..., x_n-4\, are the interior knots; they divide the approximation interval [x_1\,, x_m\,] in to n-7\! sub-intervals. The coefficients c_1\,, c_2\,, ..., c_n-4\, are then determined as the solution of the following constrained minimization problem:

minimize

\eta =\sum_{i=5}^{n-4}\delta _i^2\,

subject to the constraint

\theta =\sum_{r=1}^m\varepsilon _r^2\leq S\,

where \delta _i\, stands for the discontinuity jump in the third order derivative of y\! at the interior knot x_i\,, \varepsilon _r\, denotes the weighted residual w_r (y_r-y(x_r))\,, and S is a non-negatative number to be specified by the user.

The quantity \eta\, can be seen as a measure of the (lack of) smoothness of y\!, while closeness of fit is measured through \theta\,. By means of the parameter S\!, 'the smoothing factor', the user will then control the balance between these two (usually conflicting) properties. If S\! is too large, the spline will be too smooth and signal will be lost (underfit); if S\! is too small, the spline will pick up too much noise (overfit). In the extreme cases the function will return an interpolating spline (\theta\,=0) is S\! is set to zero, and the weighted least-squares cubic polynomial (\eta\,=0) is S\! if set very large. Experimenting with S\! values between these two extremes should result in a good compromise.

References

1. Michelle Schatzman. Numerical Analysis: A Mathematical Introduction, Chapters 4 and 6. Clarendon Press, Oxford (2002).

2. William H. Press, etc. Numerical Recipes in C++. 2nd Edition. Cambridge University Press (2002).

3. Nag C Library Function Document, nag_1d_spline_fit (e02bec).