Reposting as per Mark's request and including some keywords to make this easier to find for others in the future.
Dear all,
As I mentioned previously, I am trying to fit optical transmission through a material to find its optical resonant frequency. As can be seen in the data file linked below, the light has a transmittance through the material equal to 1 (100%) for most wavelengths in the parametric sweep, except for a particular range of frequencies, where the light resonates with the thickness and refractive index of the material and transmittance drops to near 0. This relationship looks like an inverse Lorentzian (or Cauchy for mathematicians) distribution, with an amplitude of -1 added onto a constant model with constant c equal to 1.
When the code posted is ran, the following report is created:
[[Model]]
(Model(constant, prefix='c_') + Model(lorentzian, prefix='l_'))
[[Fit Statistics]]
# fitting method = leastsq
# function evals = 3
# data points = 51
# variables = 2
chi-square = 2.50914788
reduced chi-square = 0.05120710
Akaike info crit = -149.606004
Bayesian info crit = -145.742353
## Warning: uncertainties could not be estimated:
l_center: at initial value
l_sigma: at initial value
[[Variables]]
c_c: 1 (fixed)
l_amplitude: -1 (fixed)
l_center: 5.9000e+14 (init = 5.9e+14)
l_sigma: 1.00000000 (init = 1)
l_fwhm: 2.00000000 == '2.0000000*l_sigma'
l_height: -0.31830990 == '0.3183099*l_amplitude/max(2.220446049250313e-16, l_sigma)'
Some values are purposefully fitted to make the fit as closely related to the theoretical ideal as possible. The most important parameter to have the library fit is l_center, the resonant frequency of the negative Lorentzian distribution, as it is desired to test the coupling strength of a cavity using said material. As you can see from the code, lmfit is just inserting the initial values, 5.9e14, instead of fitting it to the raw data provided and lmfit reports:
## Warning: uncertainties could not be estimated:
That being said, the program itself does not return an error, just the library.
Please let me know if there is something I am missing here as the documentation does not offer any specific examples relevant to complex models that use inverse (negative) models.
Best,
Alexandros