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
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