-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible wrong polyfit documentation #16842
Comments
Hello @davidedalbosco , thanks for bringing this up. Looks like that comment was added in this PR and from what I understand your observation is correct. This is when that comment was added; note that in the code the scaling factor is |
I'm coming here from the stackoverflow question. I confirm that the present implementation is reasonable and that just the docstring needs to be updated. I don't know enough about Bayesian statistics. |
Indeed, the documentation seems to have not been updated quite right. Sorry! Would be wonderful if someone could make a quite PR... |
I am new to git, but I tried to do a pull request, you can find it at the link Hopefully I didn't do anything wrong. |
Hi! I think that the documentation of numpy polyfit could be misleading/wrong when describing the scaling factor for the covariance matrix.
Indeed with the option
cov=True
, the covariance matrix is scaled so to return a unit value for reduced chi2 of the fit.I, therefore, expect that the scaling factor should be chi2/(M-N) = chi2/dof, where M is the number of data points and N the parameters of the fit.
However, the documentation reports that the scaling factor is chi2/sqrt(N-dof), where I guess N is the number of data points.
I did a test and actually the scaling factor I found is consistent with chi2/dof, rather than the expression reported in the documentation.
Reproducing code example:
As you can see the real scaling factor is equal to "my_scale_factor", i.e. chi2/dof.
Numpy/Python version information:
1.18.5 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]
The text was updated successfully, but these errors were encountered: