-
Hi everyone, Interestingly, it seem to work when using import numpy as np
from lmfit.models import LinearModel
np.random.seed(1)
# real data
a = 1e-13
b = 0.1
y_err = 1e-14
x = np.linspace(0, 5, 8)
y = a*x+b + np.random.normal(0, y_err, x.shape)
model = LinearModel()
params = model.guess(y, x=x)
result = model.fit(y, params, x=x)
print(result.fit_report()) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@bleolta Actually, the fit does succeed. Evaluating the uncertainties does not. That is because the value of one of the variables is extremely close to the machine precision estimate of 0, and the "noise" added to your data is extremely small, again close to machine precision. That means that the chi-square is also exceptionally small, and so that it is very hard to estimate uncertainties. If, for example, you changed This is a well-known feature of using floating point numbers. It is not something we are going to attempt to fix. It is always recommended to scale parameters to have magnitudes in the range of 1e-10 to 1e10. |
Beta Was this translation helpful? Give feedback.
@bleolta Actually, the fit does succeed. Evaluating the uncertainties does not.
That is because the value of one of the variables is extremely close to the machine precision estimate of 0, and the "noise" added to your data is extremely small, again close to machine precision. That means that the chi-square is also exceptionally small, and so that it is very hard to estimate uncertainties. If, for example, you changed
a
to 1.e-9, both the fit and estimation of the uncertainties would "work".If you had set
a
to 1.e-12 and the noise scale to 1.e-12, both woould have worked.This is a well-known feature of using floating point numbers. It is not something we are going to attempt to fix. It …