Even degree order exact polynomial equation/function for the curve fitting Data
Show older comments
I have the following data for x and y which is i am reading this data from excel file named "Ashish" by using the “excelread” command, I have attached this file with this question. After plotting this data by using plot(x, y) command, I am getting the following curve presented in image-1,

and by using the following command:
if true
% code
end
load enso;
[curve, goodness, output] = fit(Y1,Y2,'smoothingspline')
plot(curve,Y1,Y2);
xlabel('Y1');
ylabel('Y2');
I am getting the smooth spline curve for the same data shown in image-2,

and parallaly the parameter which are generated by matlab in command window for this smooth spline curve are curve =
Smoothing spline:
curve(x) = piecewise polynomial computed from p
Coefficients:
p = coefficient structure
goodness =
sse: 1.1281
rsquare: 0.9999
dfe: 201.1388
adjrsquare: 0.9997
rmse: 0.0749
output =
numobs: 501
numparam: 299.8612
residuals: [501x1 double]
Jacobian: []
exitflag: 1
p: 0.9991
But my main problem is that i want to know the exact polynomial equation/function of this smooth spline curve which is exactly fitted with my original curve shown in image-1, but this polynomial equation should have only the even degree variables for example a*x^4+b*x^2+c
Answers (1)
dpb
on 21 Apr 2016
Coefficients will be in the output structure
curve.p.coefs
which will be a Nx4 array of cubic polynomial coefficients for the N segments. They will not, however, be even-powered coefficients only as a smoothing spline will not center the data at the various segment peaks even though the input data might actually be symmetric about those local maxima(*). You'd have to transform the data itself and fit such a model manually to obtain that type of fit.
(*) But, of course, it isn't; consider the lobe around 1540; it has different "tails" so unless you truncate the right side to match the left, fitting won't return exactly a symmetric result--of course, you could only fit the even terms in the model and get reasonably close, probably.
4 Comments
Ashish Kumar
on 21 Apr 2016
dpb
on 21 Apr 2016
As said, it'll be a 3rd-order polynomial w/ coefficients given by the above structure and breakpoints defined in curve.p.breaks. Each segment will be C1*x^3 + C2*x^2 + C3*x + C4 with a different set of C for each segment between breakpoints. With your sample, it will be a foregone conclusion the breaks will be at the lobe intersections so will be 11 piecewise continuous sections. Note that your fitted plot off to the right doesn't behave as you might think--extrapolation is very risky.
John D'Errico
on 21 Apr 2016
Just to augment what dpb said - I think you expect 12 different even order polynomial segments, since there are 12 distinct domains where the curve looks like a roughly quadratic polynomial.
That is NOT how a spline works however. There will in fact be hundreds of tiny polynomial segments, all with their own sets of coefficients, all entirely different, with only the requirement of sufficient continuity and smoothness.
As for their having only even order terms, this is simply wrong. A simple counterexample is always sufficient.
Consider the 4th order polynomial, y(x)=x^4. Shift that polynomial, by 1, effectively evaluating the polynomial as a function
y(x+1) = x^4 + 4*x^3 + 6*x^2 + 4*x + 1
This polynomial is still perfectly symmetric looking, as long as you view it around the proper axis of symmetry.
However, the result that you rely on, that a polynomial which is symmetric around the y axis has only even order terms - this result fails to be valid under translation.
Finally, you need to consider that even tiny perturbations in the shape of those curves would introduce odd order terms, especially given the way a spline is constructed.
Ashish Kumar
on 21 Apr 2016
Categories
Find more on Splines in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!