aptknt
Acceptable knot sequence
Syntax
knots = aptknt(tau,k)
[knots,k] = aptknt(tau,k)
Description
knots = aptknt(tau,k)
returns a knot sequence suitable for interpolation at the data sitestau
by splines of order k with that knot sequence, providedtau
has at leastk
条目,不减少的,满足tau(i)
<tau(i+k-1)
for alli
. In that case, there is exactly one spline of orderk
with knot sequenceknots
that matches given values at those sites. This is so because the sequenceknots
returned satisfies the Schoenberg-Whitney conditions
knots(i) < tau(i) < knots(i+k), i=1:length(tau)
with equality only at the extreme knots, each of which occurs with exact multiplicityk
.
Iftau
has fewer thank
entries, thenk
is reduced to the valuelength(tau)
. An error results iftau
fails to be nondecreasing and/ortau(i)
equalstau(i+k-1)
for somei
.
[knots,k] = aptknt(tau,k)
also returns the actualk
used (which equals the smaller of the inputk
andlength(tau)
).
Examples
Iftau
is equally spaced, e.g., equal tolinspace(a,b,n)
for somen
>=4, andy
is a sequence of the same size astau
, thensp = spapi(aptknt(tau,4),tau,y)
gives the cubic spline interpolant with the not-a-knot end condition. This is the same cubic spline as produced by the commandspline(tau,y)
, but in B-form rather than ppform.
Cautionary Note
Iftau
is very nonuniform, then use of the resulting knot sequence for interpolation to data at the sitestau
may lead to unsatisfactory results.
Algorithms
The(k-1)
-point averagessum(tau(i+1:i+k-1))/(k-1)
of the sequencetau
, as supplied byaveknt(tau,k)
, are augmented by ak
-foldtau(1)
and ak
-foldtau(end)
. In other words, the command gives the same result asaugknt([tau(1),aveknt(tau,k),tau(end)],k)
, providedtau
has at leastk
entries andk
is greater than 1.