16.2 Interpolate/Extrapolate Y from X
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 a vector Y based on the input curve (XY Range). Origin provides four options for data interpolation: Linear, Cubic spline, Cubic B-spline, Akima Spline.
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.
To Interpolate Y from X
- Create a new worksheet with input data.
- Select desired data.
- Select Analysis: Mathematics:Interpolate/Extrapolate Y from X. This opens the interp1 dialog.
The interp1 X-Function is called to perform the calculation.
Note: To generate uniform linearly spaced interpolated values, use the Interpolate/Extrapolate... menu command.
Controls recalculation of analysis results
For more information, see: Recalculating Analysis Results
|X Values to Interpolate
The vector to interpolate on.
The XY range to be interpolated.
For help with range controls, see: Specifying Your Input Data
Specify interpolation methods
- 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.
- Akima Spline
- This method is based on a piecewise function composed of a set of polynomials. The akima interpolation is stable to outliers.
When parts of the data range specified by X Values to Interpolate is outside that of the X range specified in Input, these range parts will be considered as the extrapolated range, because the resulted Y values for these parts will be computed from extrapolation. This option can then be used to specify how to extrapolate the corresponding Y values.
- Extrapolate Y using the last two points
- Set missing
- Set all Y values in the extrapolated range to be missing values.
- Repeat the last value
- Use the Y value of the closest input X value for all values in the extrapolated range.
Boundary condition is only available in cubic spline method.
- 2nd derivatives are 0 on both ends.
- 3rd derivatives are continuous on the second and last-second point.
Smoothing is only available in Cubic B-Spline method.
|Result of interpolation
The output vector.
Output the coefficients for Spline or B-spline method or not, and show them in which column.
Given a sequence of distinct pairs of data (, ), where . we are looking for the interpolated at by the following methods:
1. Linear interpolation (interp1q)
2. Cubic spline (spline)
Origin uses the natural cubic spline to do interpolation:
And can be generated from:
For boundary points, we set and equal to zero.
3. Cubic B-spline (bspline)
For or perform linear interpolation.
Here, denotes the normalized cubic B-spline defined upon the knots , , ..., , And denotes the coefficient of the corresponding function.
The total number of these knots and their values , ..., are chosen automatically by the function. The knots , ..., are the interior knots; they divide the approximation interval [, ] in to sub-intervals. The coefficients , , ..., are then determined as the solution of the following constrained minimization problem:
subject to the constraint
where stands for the discontinuity jump in the third order derivative of at the interior knot , denotes the weighted residual , and S is a non-negatative number to be specified by the user.
The quantity can be seen as a measure of the (lack of) smoothness of , while closeness of fit is measured through . By means of the parameter , 'the smoothing factor', the user will then control the balance between these two (usually conflicting) properties. If is too large, the spline will be too smooth and signal will be lost (underfit); if is too small, the spline will pick up too much noise (overfit). In the extreme cases the function will return an interpolating spline (=0) is is set to zero, and the weighted least-squares cubic polynomial (=0) is if set very large. Experimenting with values between these two extremes should result in a good compromise.
4. Akima Spline (akima)
The Akima interpolation method is based on a piecewise function composed of a set of polynomials(third degree at most). This piecewise function can be applied to successive intervals of the given XY points. The slope of the input data plot at each given point can be assumed to be determined by the XY coordinates of 4 neighbor points and the point itself. Then from the slopes at two paired given points and their coordinates, a third degree polynomial is calculated, representing the interval curve between these two points, and the interpolation is then carried out based on the combination of polynomials. An additional estimation is made when calculating polynomials for end points.
Firstly the curve slope at a given point will be calculated. For a given point (point 3), there will then be five data points 1,2,3,4,5, and are slopes of line segments respectively, and . The curve slope is then determined by the following equations under different conditions:
When or ,
When and ,
Slopes for two end points need to be estimated at each end of the curve. To estimate them, we calculate its slope by interpolating a parabolic curve from its adjacent three points, e.g. for the first point's slope, we can interpolate a parabolic curve from first three points, and the first point's slope can be calculated by the derivative of the interpolated curve.
Then the polynomial for an interval between two consecutive data points and are determined by the following four conditions:
where and are the slopes at the two points.
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).
4. Hiroshi Akima, Journal of the Association for Computing Machinery, Vol. 17, No. 4, (1970)