[SciPy-User] How to estimate error in polynomial coefficients from scipy.polyfit?

David Warde-Farley dwf at cs.toronto.edu
Thu Mar 25 16:49:51 EDT 2010


On 25-Mar-10, at 4:32 PM, Jeremy Conlin wrote:

> Now I would like to know how I can get the uncertainties
> (standard deviations) of polynomial coefficients from the returned
> values from scipy.polyfit.  If I understand correctly, the residuals
> are sometimes called the R^2 error, right?

No, that's not what R^2 is. See http://en.wikipedia.org/wiki/Coefficient_of_determination

The residuals plus some assumptions about the kind of noise present in  
your data can tell you something about the standard deviation of a  
given predicted function value, but I'm not sure how to turn that into  
a measure of uncertainty on the coefficient itself. My first instinct  
would be to do it with bootstrap samples, i.e. if you have N data  
points, sample with replacement from that data to generate, say, 100  
sets of size N, fit the coefficients on each of them, and take the  
empirical standard deviation. I am not sure how polyfit responds to  
duplicated points, however, though it should reweight your least  
squares estimate a bit.

David



More information about the SciPy-User mailing list