[Numpy-discussion] polyfit in NumPy v1.7
Pauli Virtanen
pav at iki.fi
Wed Feb 27 12:47:07 EST 2013
27.02.2013 16:40, David Pine kirjoitti:
[clip]
> 2. I am sorry but I don't understand your response. The matrix Vbase
> in the code is already the covariance matrix, _before_ it is scaled by
> fac. Scaling it by fac and returning Vbase*fac as the covariance
> matrix is wrong, at least according to the references I know, including
> "Numerical Recipes", by Press et al, "Data Reduction and Error Analysis
> for the Physical Sciences" by Bevington, both standard works.
The covariance matrix is (A^T A)^-1 only if the data is weighed by its
standard errors prior to lstsq. Polyfit estimates the standard errors
from the fit itself, which results in the `fac` multiplication.
This is apparently what some people expect. The way the weight
parameters work is however confusing, as they are
w[i]=sigma_estimate/sigma[i], rather than being absolute errors.
Anyway, as Josef noted, it's the same problem that curve_fit in Scipy
had and probably the same fix needs to be done here.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list