Smoothing spline (spaps)

Hi, I've got a question concerning the behaviour of the 'spaps' function (smoothing spline in curve fitting toolbox). It works as expected if the input vector contains large numbers, but does not seem to work for small numbers. An example:
This behaves as I would expect it:
x = 1:20;
y = 10 + 2*randn(20,1);
tol = ones(20,1);
sp = spaps(x,y,tol); % smoothing spline
subplot(2,1,1)
errorbar(x,y,tol,'LineStyle','none');
hold on
xi = 1:0.1:20;
plot(xi,fnval(sp,xi),'r');
title('spaps(x,y,tol)')
hold off
Now the same as above, but the y and tol values multiplied by 0.01. I would expect the same curve as above (also multiplied by 0.01), but instead the smoothing parameter is 0 resulting in a straight line fit.
scale = 0.01;
y = y*scale;
tol = tol*scale;
sp = spaps(x,y,tol);
subplot(2,1,2)
errorbar(x,y,tol,'LineStyle','none');
hold on
xi = 1:0.1:20;
plot(xi,fnval(sp,xi),'r');
title('spaps(x,0.01*y,0.01*tol)')
hold off
Why is 'spaps' not scaleable?

 Respuesta aceptada

Andrew Newell
Andrew Newell el 24 de Jun. de 2011

0 votos

Interesting question. I don't know anything about the algorithm, but the documentation says that the distance being minimized is a sum of squares, so I thought I'd try
tol = tol*scale^2;
It works, producing a fit that lies on top of the first fit when divided by scale.

Más respuestas (0)

Categorías

Preguntada:

el 24 de Jun. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by