How to get a accurate or near accurate extrapolation in interp1?
103 views (last 30 days)
Show older comments
if 'extrap' extrapolation is used, the new vector doesn't give expected result. If zero is filled in the extrapolation points, the result somewhat matches the expected result.
Is there any other extrapolation algorithm which can give better accuracy?
program here,
a=[ 2 4 7 9 3 6 8]; % vector
xold=linspace(3,9,7); % old x axis
xnew=linspace(1,11,11); % new x axis
anew=interp1(xold,a,xnew,'spline','extrap'); % new vector
% anew=interp1(xold,a,xnew,'spline',0); % new vector
2 Comments
Adam
on 20 May 2016
'linear' or 'pchip' will give extrapolation results a little more "sensible", but whether they are what is expected or not is another matter. Extrapolation, by its nature, is not clearly defined and using splines defined over such a small set of points does seem to result in some wild results. There is no such thing as 'accuracy' as such though for extrapolation, it depends entirely on the algorithm by which you choose to extrapolate.
Accepted Answer
John D'Errico
on 20 May 2016
Extrapolating a spline is insane, dangerous, crazy, random ... Just pick your word. They all apply.
Accurate is hardly ever a word that will apply, at least in context of a meaningful sentence about extrapolation and splines. Ok, I can do that if I try. Perhaps this: "Extrapolation of a spline beyond the support of the data will rarely if ever be an accurate predictor of the underlying function."
I once wrote a routine that would take an existing spline, then creating a new spline that extrapolated the old. It allowed the user to provide information about how one should do the extrapolation. I've wanted to re-write code for that purpose many times. On the round-tu-it list.
The point is that you cannot extrapolate a cubic segment accurately unless you know how that extrapolant should behave. Should it be monotonic? Linear? Could it roll over? Approach an asymptote?
In general, even when I wrote that code many years ago, I usually recommended that it was better to build the spline FIRST over the entire domain of interest (including the extrapolated domain) using the necessary information. Since you can do that using my SLM toolbox, I've never really had the desire to re-write the extrapolant code.
So my recommendation is that you use SLM to build the spline in the first place, where you build the spline out as far as necessary. Apply all necessary information about the shape of the spline in the extrapolated region when you build the spline. Then you can evaluate that spline to your heart's content.
0 Comments
More Answers (0)
See Also
Categories
Find more on Spline Construction in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!