Smoothing
Syntax: |
vout = SMOOTH(x,y,xout)
|
Defaults: |
w[1:#] = 1
|
Smoothing means that the output may not pass through the original data. If it is important that the curve
pass through the original data, use
the INTERPOLATE
function,
unless your independent variable is not monotonically increasing. In that case, use
the SPLINTERP
function.
For 2D interpolation, use the
BIVINTERP
function.
The SMOOTH
function calculates a smooth curve using the method of cubic
splines under tension. The data is contained in vectors x
, the
independent variable, and y
, the dependent variable. A vector is
returned with the same length as xout
, the output locations
vector. Vectors x
and xout
must
be strictly monotonically increasing, with x[1] ≤ xout[j] ≤ x[#]
for j=1,2,...,LEN(xout)
SPLSMOOTH function
The SPLSMOOTH
function calculates a smooth curve through the data
contained in x
, the independent variable,
and y
, the dependent variable. x
need not be increasing. The number of output locations is given in
scalar n
. The output of this function is a matrix
with n
rows and 2
columns. The first column will contain
the output locations and the second column the smoothed values.
The points are first parameterized in terms of normalized arc length. The normalized length
of x
is the real length divided by the range
of x
, that is, the maximum value minus the minimum value. The arc
length at a point is approximated by the sum of the lengths of straight line segments connecting
all points up to that point. A spline under tension is calculated for x
versus arc
length and y
versus arc
length. The x
and y
values are
interpolated separately and then combined to form the output interpolant.
Weights
If no weights, w
, are entered, the weight at each data point defaults
to 1
. The weights control the amount of smoothing at each data point. As the weight at a point
decreases, the spline fits that data point more closely.
Spline tension
Depending on the tension, the smoothed curve may not pass through the original data points. The tension
corresponds to the curviness, and must be > 0
. As the tension decreases, the amount of
smoothing decreases and the data points are fit more exactly. If it is close to zero, each
smoothing function is almost a cubic spline and the resulting curve is quite loose. As the tension
increases, the fit straightens and has less curvature at peaks, valleys and endpoints. If the tension
is large, the smoothing is almost linear and the result approaches the least-squares line through the
data. The default value for the tension is zero, and the tension is controlled with
the TENSION
characteristic.
Method
Given a set of abscissae: , a cubic spline function over the
region
is composed of cubic parabolas
where , which join at the endpoints
such
that
,
, and
are continuous.
The smoothing function is constructed by minimizing
subject to the constraint
where are
the weights and
is the spline tension.
The solution proceeds by the standard methods of minimizing the functional
where and
are auxiliary parameters.
The functional is minimized with respect to
and
by setting the partial
derivatives with respect to
and
equal to zero.