SPLINE Function
Standard Library function that performs a cubic spline interpolation.
Usage
result = SPLINE(x, y, t [, tension])
Input Parameters
x—A vector containing the independent coordinates of the dataset. The vector must be monotonic and increasing.
y—A vector containing the dependent coordinates of the dataset.
t—A vector containing the independent coordinates for which the ordinates are desired. Must be monotonic and increasing.
tension—(optional) The amount of tension to be put on the spline curve. The default value is 1.0 (see Discussion).
Returned Value
result—A vector containing interpolated ordinate values. In other words,
result(i) = value of the function at T(i).
Keywords
None.
Discussion
SPLINE performs a cubic spline interpolation of the input vector in order to obtain a vector of interpolated dependent values. The dependent values are calculated at the independent values given by the vector t.
A tension curve always passes through each known data point. The optional tension parameter controls the smoothness of the fitted curve. The higher the tension, the more closely the curve approximates the set of line segments that connect the data points. A lower tension produces a smoother curve that may deviate considerably from the straight-line path between points.
When tension is set close to zero (e.g., 0.01), the curve is virtually a cubic spline fit. When tension is set to a large value (e.g., >10.0), then the fitted curve will be similar to that obtained from a polynomial interpolation, such as POLY_FIT or POLYFITW.
The SPLINE function can be useful for those applications where you need to fit the data with a smoother or stiffer curve than that obtained with an interpolating polynomial. Splines also tend to be more stable than polynomials, with less possibility of wild oscillation between the data points.
Example 1
; Create the data.
x = FINDGEN(10)
y = RANDOMN(seed, 10)
; Create a vector containing the independent points at which
; the dependent points are calculated.
t = FINDGEN(100)/11.
; Plot the original data.
PLOT, y
; Plot using 100 independent points and a default tension of 1.
PLOT, t, SPLINE(x, y, t), Xstyle=4, Ystyle=4, /Noerase, $
linestyle=2
; Plot using 100 independent points and a tension of 8.
PLOT, t, SPLINE(x, y, t, 8.), Xstyle=4, Ystyle=4, /Noerase, $
Linestyle=3
Example 2
; X values of the original function.
x = [2.0, 3.0, 4.0]
; Y formed from a quadratic function.
y = (x - 3)^2
; Twenty values from 2 to 3.90 for the interpolated points.
t = FINDGEN(20) / 10. + 2
; Do the interpolation.
z = SPLINE(x, y, t)