[Numpy-discussion] Change in default behavior of np.polyfit
nussbaum at uni-mainz.de
Fri Jun 1 08:24:48 EDT 2018
in  the scaling factor for the covariance matrix of `np.polyfit` was
discussed. The conclusion was, that it is non-standard and a patch might be
in order to correct this. Pull request  changes the factor from
chisq(popt)/(M-N-2) to chisq(popt)/(M-N) (with M=number of point, N=number
of parameters) essentially removing the "-2". Clearly, this changes the
result for the covariance matrix (but not the result for the polynomial
coefficients) and therefore the current behavior if `cov=True` is set.
It should be noted, that `scipy.optimize.curve_fit` also uses the
chisq(popt)/(M-N) as scaling factor (without "-2"). Therefore, the change
would remove a discrepancy.
Additionally, patch  adds an option that sets the scaling factor of the
covariance matrix to 1 . This can be useful in occasions, where the weights
are given by 1/sigma with sigma being the (known) standard errors of
(Gaussian distributed) data points, in which case the un-scaled matrix is
already a correct estimate for the covariance matrix.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion