Skip to content
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

Fit routines break r_values #21

Closed
s-kuberski opened this issue Dec 3, 2021 · 1 comment · Fixed by #23
Closed

Fit routines break r_values #21

s-kuberski opened this issue Dec 3, 2021 · 1 comment · Fixed by #23
Assignees
Labels
bug Something isn't working

Comments

@s-kuberski
Copy link
Collaborator

s-kuberski commented Dec 3, 2021

import pyerrors as pe
def f(a, x):
    return a[0] + a[1] * x

a1 = pe.pseudo_Obs(1.1, .1, 'a|1')
a2 = pe.pseudo_Obs(1.2, .1, 'a|2')
a = pe.merge_obs([a1, a2])
b = pe.pseudo_Obs(2, .001, 'b')
c = pe.pseudo_Obs(3, .001, 'c')

y = [a, b, c]
[o.gamma_method() for o in y]
fitp = pe.fits.least_squares([1, 2, 3], y, f)
print(fitp)
for o in fitp:
    print(o.value, o.r_values)

gives

Fit with 2 parameters
Method: Levenberg-Marquardt
`xtol` termination condition is satisfied.
chisquare/d.o.f.: 4.5022309160171705
Goodness of fit:
χ²/d.o.f. = 4.502231
Fit parameters:
0	 0.0002(36)
1	 0.9999(14)

0.0002401189830877699 {'a|1': 1.1000000000000003, 'a|2': 1.2, 'b': 1.15, 'c': 1.15}
0.9999099553831112 {'a|1': 1.1000000000000003, 'a|2': 1.2, 'b': 1.15, 'c': 1.15}

which is clearly wrong.

result.append(derived_observable(lambda x, **kwargs: x[0], list(y), man_grad=list(deriv[i])))

@s-kuberski s-kuberski added the bug Something isn't working label Dec 3, 2021
@s-kuberski
Copy link
Collaborator Author

Something like

result.append(derived_observable(lambda x, **kwargs: x[0] / y[0].value * fit_result.x[i], list(y), man_grad=list(deriv[i])))

seems to resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants