title: lmfit model for multi exponential decay
body: <p>I am trying to perform a fitting for my data using the <strong>lmfit package</strong>. However I couldnt find any built-in model for a multi-exponential decay. I have tried to create my own function, and then to fit it.
  My code is the following:</p>
  <pre><code>import os
  import time
  import numpy as np
  import pandas as pd
  import lmfit
  from lmfit.models import ExponentialModel, LinearModel
  from lmfit import Model, Parameter, report_fit
  
  def MultiExpDecay(tiempo,C1,tau1,C2,tau2):
      return C1*np.exp(-tiempo/tau1)+C2*np.exp(-tiempo/tau2)
  
  def MultiExpDecay_fit():
      C1s = []
      C1s_error = []
      C2s = []
      C2s_error = []
      tau1s = []
      tau1s_error = []
      tau2s = []
      tau2s_error = []
      Fit_MultiExpDecays = []
      model = Model(MultiExpDecay, independent_vars=['tiempo'])
      for c in range(len(V_APD.columns)):
          xdat = tiempo.iloc[:, c]
          ydat = V_APD.iloc[:, c]
          pars = model.guess(ydat, x=xdat)
          fit = model.fit(ydat, pars, x=xdat)
          fit_values = model.eval(pars, x=xdat)
          Fit_MultiExpDecays.append(fit_values)
          for key in fit.params:
              if key == 'C1':
                  #print(key, &quot;=&quot;, out.params[key].value, &quot;+/-&quot;, out.params[key].stderr)
                  C1s.append(fit.params[key].value)
                  C1s_error.append(fit.params[key].stderr)
              elif key == 'C2':
                  C2s.append(fit.params[key].value)
                  C2s_error.append(fit.params[key].stderr)
              elif key == 'tau1':
                  tau1s.append(fit.params[key].value)
                  tau1s_error.append(fit.params[key].stderr)
              elif key == 'tau2':
                  tau2s.append(fit.params[key].value)
                  tau2s_error.append(fit.params[key].stderr)
      Fit_MultiExpDecays = np.transpose(pd.DataFrame(Fit_MultiExpDecays, index=labels))
      C1 = np.transpose(pd.DataFrame(C1s, index = labels, columns = ['C1']))
      C2 = np.transpose(pd.DataFrame(C2s, index=labels, columns=['C2']))
      tau1 = np.transpose(pd.DataFrame(tau1s, index=labels, columns=['tau1']))
      tau2 = np.transpose(pd.DataFrame(tau2s, index=labels, columns=['tau2']))
      C1_error = np.transpose(pd.DataFrame(C1s_error, index = labels, columns=['C1 error']))
      C2_error = np.transpose(pd.DataFrame(C2s_error, index=labels, columns=['C2 error']))
      tau1_error = np.transpose(pd.DataFrame(tau1s_error, index=labels, columns=['tau1 error']))
      tau2_error = np.transpose(pd.DataFrame(tau2s_error, index=labels, columns=['tau2 error']))
      C1 = pd.concat([C1, C1_error])
      C2 = pd.concat([C2, C2_error])
      tau1 = pd.concat([tau1, tau1_error])
      tau2 = pd.concat([tau2, tau2_error])
      return C1, C2, tau1, tau2, Fit_MultiExpDecays
  
  C1, C2, tau1, tau2, Fit_MultiExpDecays = MultiExpDEcay_fit():
  </code></pre>
  <p>An error is raised but cannot identify the problem.</p>
  <pre><code>File &quot;C:\ProgramData\Anaconda3\Lib\site-packages\lmfit\model.py&quot;, line 737, in guess
      raise NotImplementedError(msg)
  NotImplementedError: guess() not implemented for Model
  </code></pre>