Hm,
Sorry for the trouble, but I'm not sure what you are seeing. There are "parameter hints" for gamma, but I think those should be superceded by explicit parameter settings when doing a fit.
Without a runnable example, it is very hard to guess what is happening. Please attach a more complete example. If you are doing a fit, always look at (and include here), the fit report.
For sure, the exponential Gaussian model is prone to getting Inf and NaN values when gamma*sigma is large. That “large” is “in comparison to x”, so is sort of hard to define ahead of time. Maybe checking for Inf/nan inside the expgaussian() function would be a good idea.
For me, this:
##
import numpy as np
from lmfit.models import ExponentialGaussianModel
from lmfit.lineshapes import expgaussian
x = np.linspace(0, 8, 101)
y = expgaussian(x, amplitude=10, center=3.4, sigma=0.5, gamma=1.1)
y += np.random.normal(size=len(x), scale=0.1)
mod = ExponentialGaussianModel()
params = mod.make_params(
amplitude = {'value': 15, 'min': 0, 'max': 100},
center = {'value': 3.1, 'min':0, 'max': 10},
sigma = {'value': 0.3, 'min': 0, 'max': 5},
gamma = {'value': 1.2, 'min': -2, 'max': 2} )
out = mod.fit(y, params, x=x)
print(out.fit_report())
for p in out.params.values():
print(p)
##
Gives this:
#
[[Model]]
Model(expgaussian)
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 31
# data points = 101
# variables = 4
chi-square = 0.94859320
reduced chi-square = 0.00977931
Akaike info crit = -463.457471
Bayesian info crit = -452.996989
R-squared = 0.99626192
[[Variables]]
amplitude: 10.0289448 +/- 0.06648889 (0.66%) (init = 15)
center: 3.39397130 +/- 0.00883240 (0.26%) (init = 3.1)
sigma: 0.49718993 +/- 0.00850831 (1.71%) (init = 0.3)
gamma: 1.08027009 +/- 0.02249352 (2.08%) (init = 1.2)
[[Correlations]] (unreported correlations are < 0.100)
C(center, gamma) = +0.8068
C(sigma, gamma) = +0.6500
C(center, sigma) = +0.5245
C(amplitude, gamma) = -0.5164
C(amplitude, center) = -0.4166
<Parameter 'amplitude', value=10.028944771049531 +/- 0.0665, bounds=[0:100]>
<Parameter 'center', value=3.393971295584311 +/- 0.00883, bounds=[0:10]>
<Parameter 'sigma', value=0.4971899318045095 +/- 0.00851, bounds=[0:5]>
<Parameter 'gamma', value=1.0802700861294188 +/- 0.0225, bounds=[-2:2]>
#
Maybe that will help. If not, please explain what you are doing in more detail.
From: lmfi...@googlegroups.com <lmfi...@googlegroups.com> on behalf
of Ivo Vinklárek <vinkla...@gmail.com>
Sent: Monday, July 29, 2024 1:51 PM
To: lmfit-py <lmfi...@googlegroups.com>
Subject: ExponentialGaussianModel - a bug in code?
Dear lmfit community,
Here I give a simple example (I work in Jupyter notebook):
from lmfit.models import ExponentialGaussianModel
eg_mod = ExponentialGaussianModel(prefix = 'eg_', nan_policy='omit')
# parameters gaussian-exponential
params = eg_mod.make_params(
eg_amplitude = dict(value = 15, min = 0, max = 40),
eg_center = dict(value = -1, min = -50, max =50),
eg_sigma = dict(value = 15, min = 0, max = 100),
eg_gamma = dict(value = 4, min = 2, max = 18),
)
params
The outcome of such a code is a matrix of parameters. However, the
eg_gamma parameter seems to have predefined min and max values independent of my input!
Here is the outcome (look at the bottom line of the picture outcome and compare it with my code):
Could someone from the developers check that this is a bug so I can report it as an issue? ...or show me what I am doing wrong? :-) I already played with it for a long time trying to change prefixes and numbers, etc. and nothing helped.
Btw.:
python: 3.9.16 lmfit: 1.3.1
Thank you in advance,
Best regards,
Ivo
--
You received this message because you are subscribed to the Google Groups "lmfit-py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
lmfit-py+u...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lmfit-py/9b5dd120-f913-4f4f-a640-6e8b68a679ben%40googlegroups.com.