uniform knot vector for splines

Suppose we have uniform interpolation points, e.g
x = [1 2 3 4 5 6]
x = 1x6
1 2 3 4 5 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The functions for knot generation produce knots of the form
t = aptknt(x,5)
t = 1x11
1.0000 1.0000 1.0000 1.0000 1.0000 3.5000 6.0000 6.0000 6.0000 6.0000 6.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
where the first and last knot is repeated k times, but the breaks are no longer uniform. Similar for other knot functions like optknt.
I would like to carry over the property of equal distance between the interp. points to the knots. The knot vector
t = 1 1 1 2 3 4 5 6 6 6 6
satisfies this, as well as the Schoenberg-Whitney conditions. I arbitrarily repeated the first knot 3 times and the last knot four times.
Is such a knot vector plausible and why does MATLAB not offer functions for uniform knot sequences?

 Accepted Answer

Your knot sequence seems NOT to be suitable for interpolation. The interpolation matrix is singular.
x = linspace(1,6,6);
xi = linspace(min(x),max(x),61);
k = 5;
k1 = floor(k/2);
k2 = k-k1;
tSAW = [repelem(x(1),1,k1) x repelem(x(end),1,k2)]
tSAW = 1x11
1 1 1 2 3 4 5 6 6 6 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
t = aptknt(x,k);
for p=0:k-1
y = x.^p;
sSAW = spapi(tSAW,x,y); % Not workingn coefs are NaN
s = spapi(t,x,y);
subplot(3,2,p+1);
yiSAW = fnval(sSAW, xi);
yi = fnval(s, xi);
plot(x, y, 'ro', xi, yiSAW, 'b+', xi, yi, 'g-') % Blue curve not plotted since yiSAW are NaN
end
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
It seems Schoenberg-Whitney conditions are violated despite what you have claimed.

7 Comments

Interesting. But the Schoenberg-Whitney conditions
knots(i) < x(i) < knots(i+k), i=1:length(tau)
as stated here are satisfied.
You need to revise the spline theory, or make correct logical dediction.
k = 5;
x = linspace(1,6,6);
k1 = floor(k/2);
k2 = k-k1;
tSAW = [repelem(x(1),1,k1) x repelem(x(end),1,k2)]
tSAW = 1x11
1 1 1 2 3 4 5 6 6 6 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
n = length(tSAW) - k;
figure
hold on
% Interpolation matrix at station x
M = zeros(n);
,for i = 1:n
si = spmak(tSAW, accumarray(i, 1, [n 1])');
fnplt(si);
M(:,i) = fnval(si,x);
end
% All basis functions is 0 at first and last knots/station
% First and last rows of M contain 0s
M
M = 6x6
0 0 0 0 0 0 0.5139 0.3194 0.0417 0 0 0 0.0556 0.4444 0.4583 0.0417 0 0 0 0.0417 0.4583 0.4444 0.0556 0 0 0 0.0417 0.3194 0.5139 0.1250 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Singularity
cond(M)
ans = Inf
rank(M)
ans = 4
@SA-W knots(i) < x(i) < knots(i+k), i=1:length(tau)
This Schoenberg Whitney (SW) conditions are violated twice.
With
k = 5;
% station vector is
x = [1 2 3 4 5 6];
% Knot vector is
tSAW = [1 1 1, 2 3 4 5, 6 6 6 6];
for i = 1:
  • knot(i) = tSAW(1) = 1
  • tau(i) = x(1) = 1
  • So knots(i) is NOT < tau(i)
for i = 6:
  • knot(i+k) = tSAW(11) = 6
  • tau(i) =x(6) = 6
  • So tau(i) is NOT < knots(i+k)
% Small code to check SW condition
if SWtest(x, tSAW)
fprintf('Schoenberg Whitney test pass\n');
else
fprintf('Schoenberg Whitney test fails\n');
end
Schoenberg Whitney test fails
function OK = SWtest(x, t)
x = sort(x); t = sort(t);
n = length(x);
k = length(t)-n;
OK = true;
for i = 1:n
xi = x(i);
tl = t(i);
multiplicity = nnz(t == tl);
if multiplicity >= k
test_i = tl <= xi;
else
test_i = tl < xi;
end
tr = t(i+k);
multiplicity = nnz(t == tr);
if multiplicity >= k
test_i = test_i && xi <= tr;
else
test_i = test_i && xi < tr;
end
OK = OK && test_i;
end
end
Note that all the basis functions N_i,5 for i=1,2...6 are continuous since the (extreme) knots are repeats less than k=5 times in your case.
All of them vanish outside the support, meaning for x < 1 or x > 6 So all of them must = 0 at x = 0 and x = 6 (since they are C0). This violate SW original condition of N_i,5 (x(i)) must be > 0. This is nother way to prove Schoenberg Whitney conditions are violated.
That explains aslo why the interpolation matrix M has 2 null rows and is singular therefore not suitable for interpolation, and spapi won't work with such knot sequence.
Thanks for your detailed answer. Just a comment:
for i = 1:
  • knot(i) = tSAW(1) = 1
  • tau(i) = x(1) = 1
  • So knots(i) is NOT < tau(i)
for i = 6:
  • knot(i+k) = tSAW(11) = 6
  • tau(i) =x(6) = 6
  • So tau(i) is NOT < knots(i+k)
But the conditions are also violated at i=1 and i=6 for the knots generated by aptknt(x,5). But in your code, it is clear. Also the argumentation with the rank is clear.
The fact that the basis functions are zero at x(1) and x(end) is a consequence of having x(1) and x(end) not repeated k times in the knot vector, right?
That said, there is no way to have uniform knot breaks on the interpolation domain?
"But the conditions are also violated at i=1 and i=6 for the knots generated by aptknt(x,5). But in your code, it is clear. Also the argumentation with the rank is clear."
Please Read carefully what ever your reference on SW theorem and conditions, the test change (non strict) when knot mulltiplicity == k as I implement in my function SWtest function.
"That said, there is no way to have uniform knot breaks on the interpolation domain?"
What is the purpose of it? What if your x is non unform to start with, an assumption you never spell out.
You could chose
x = 1:6;
k = 5;
n = length(x);
dt =(max(x)-min(x))/(n-k+1);
teq = min(x) + dt*(-k+1:n)
teq = 1x11
-9.0000 -6.5000 -4.0000 -1.5000 1.0000 3.5000 6.0000 8.5000 11.0000 13.5000 16.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
OK = SWtest(x, teq)
OK = logical
1
figure
hold on
for i = 1:n
si = spmak(teq, accumarray(i, 1, [n 1])');
fnplt(si);
end
xlim([min(x) max(x)]);
or
dx = mean(diff(x));
dt = dx;
a = (n+k-1)/2;
teqx = mean(x) + dt*(-a:a)
teqx = 1x11
-1.5000 -0.5000 0.5000 1.5000 2.5000 3.5000 4.5000 5.5000 6.5000 7.5000 8.5000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
OK = SWtest(x, teqx)
OK = logical
1
figure
hold on
for i = 1:n
si = spmak(teqx, accumarray(i, 1, [n 1])');
fnplt(si);
end
xlim([min(x) max(x)]);
SA-W
SA-W on 13 Apr 2024
Edited: Bruno Luong on 13 Apr 2024
What is the purpose of it? What if your x is non unform to start with, an assumption you never spell out.
I know that my interpolant is barely sampled at some regions and I can circumvent this with the positioning of interpolation points x. For instance, when I do csape(x,y), the interpolation segments are determined by x, whereas for spapi and friends, the knot vector determiens the interpolation segments and I only have semi-control.
Anyway, if x is uniform, the knot vector aptknt(x,k) is uniform as well except at the boundary. So i can live with that. I was just wondering if there are alternatives and you provided some.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 12 Apr 2024

Edited:

on 13 Apr 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!