MATLAB - Find the error on polynomial fit parameters of experimental data

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 13K views
SK1.618
Messages
8
Reaction score
0
See attached PDF for details: How do I calculate errors on the fit parameters, p?
 

Attachments

Physics news on Phys.org
Check out the doc on polyfit and polyval. In particular,

[p,S] = polyfit(x,y,n) returns the polynomial coefficients p and a structure S for use with polyval to obtain error estimates or predictions. Structure S contains fields R, df, and normr, for the triangular factor from a QR decomposition of the Vandermonde matrix of x, the degrees of freedom, and the norm of the residuals, respectively. If the data y are random, an estimate of the covariance matrix of p is (Rinv*Rinv')*normr^2/df, where Rinv is the inverse of R. If the errors in the data y are independent normal with constant variance, polyval produces error bounds that contain at least 50% of the predictions.

[y,delta] = polyval(p,x,S) uses the optional output structure S generated by polyfit to generate error estimates delta. delta is an estimate of the standard deviation of the error in predicting a future observation at x by p(x). If the coefficients in p are least squares estimates computed by polyfit, and the errors in the data input to polyfit are independent, normal, and have constant variance, then y±delta contains at least 50% of the predictions of future observations at x.

There is also a good example on the polyfit page.