fitting exponential decay with no initial guessing

前端 未结 8 924
刺人心
刺人心 2020-12-01 02:31

Does anyone know a scipy/numpy module which will allow to fit exponential decay to data?

Google search returned a few blog posts, for example - http://exnumerus.blo

8条回答
  •  旧时难觅i
    2020-12-01 02:58

    If your decay starts not from 0 use:

    popt, pcov = curve_fit(self.func, x-x0, y)
    

    where x0 the start of decay (where you want to start the fit). And then again use x0 for plotting:

    plt.plot(x, self.func(x-x0, *popt),'--r', label='Fit')
    

    where the function is:

        def func(self, x, a, tau, c):
            return a * np.exp(-x/tau) + c
    

提交回复
热议问题