Search code examples
pythoncurve-fittingcurveleast-squaresdata-fitting

How to guess the actual lorentzian function without relaxation behavior with Least square curve fitting


I wanted to ask you if it would be possible to implement this idea:

So all in all, I measure a signal (blue curve, See plot of the measured data and the initial guess for the lorentzian function), this signal is a convolution of a lorentzian function and a certain relaxation kernel. I have an initial guess of the lorentzian function (see green curve), but as you notice, the green curve is not really aperfect lorentzian function , as it is still dissymmetric in the bottom. I have never used this tyme of curve fitting and would be really grateful if anyone could show me a little code-example to find the wanted lorentzian function or the actual relaxation kernel exp(-t/tau).

So now in steps:

  1. Say we have a lorentzian function, that decays with a certain relaxation time tau, tau is not a constant but a function of time. So say we have a measured data that we will model as a convolution between a lorentzian function and a relaxation kernel, exp(-t/tau) (please see blue curve)
  2. With a certain algorithm I implemented, I have a first guess of the "unrelaxated" lorentzian function and the relaxation kernel exp(-t/tau) (please see the green one).
  3. now I would like to do least-square curve-fitting in order to determine the best relaxation kernel and the best fit for the lorentzian function that would much my data.

Solution

  • I have used the Differential Evolution genetic algorithm that is in recent versions of scipy to aid in fitting a double Lorentzian peak equation to Raman spectroscopy data with excellent results. Change the data and fitted equation in my GitHub code to your own and you should be done.

    The GitHub URL for this project is:

    https://github.com/zunzun/RamanSpectroscopyFit