pep-dortmund / toolbox-workshop

Materialien zum PeP et al. Toolbox-Workshop
http://toolbox.pep-dortmund.org
Other
26 stars 6 forks source link

Exercise `ucurve_fit` strange behavior for `absolute_sigma=True` if `sigma=None` #394

Closed ChAr-De closed 1 year ago

ChAr-De commented 1 year ago

See this scipy issue. If we use the solution of the exercise without errors of the y parameter, the errors of the fit parameters are wrongly calculated. Maybe we should change the solution to also set absolute_sigma=False or add a comment to prevent the usage of the function if the input data has no errors.

aknierim commented 1 year ago

Just for clarification, you're talking about this line, right? https://github.com/pep-dortmund/toolbox-workshop/blob/52ed55a114bd64ee7b54bb734726023f388ba0f6/exercises-latex/13-python/curve_fit.py#L23

aknierim commented 1 year ago

I would argue for something like this then (ll. 13-16):

 if np.any(unp.std_devs(y) == 0):
        sigma = None
        abs_sigma = False
    else:
        sigma = unp.std_devs(y)
        abs_sigma = True

And then changing https://github.com/pep-dortmund/toolbox-workshop/blob/52ed55a114bd64ee7b54bb734726023f388ba0f6/exercises-latex/13-python/curve_fit.py#L23 to

absolute_sigma=abs_sigma,