title: Alternative to scipy.optimize.curve_fit
body: <p>I'm trying to plot some visualisations with matplotlib, and in one of my functions, I check if waves are logarithmic. This is my current working version:</p>
  
  <pre><code>import numpy as np
  def is_logarithmic(waves):
  
      def expfunc(x, a, b, c):
          return a*np.exp(b*x) + c
  
      wcopy = list(waves)
      wcopy.sort()
  
      # If the ratio of x-max : x-min &lt; 10, don't use a logarithmic scale
      # (at least in matplotlib)
      if (wcopy[-1] / wcopy[0]) &lt; 10:
          return False
  
      # Take a guess at whether it is logarithmic by seeing how well the x-scale
      # fits an exponential curve
      diffs = []
      for ii in range(len(wcopy) - 1):
          diffs.append(wcopy[ii + 1] - wcopy[ii])
  
      # Fit the diffs to an exponential curve
      x = np.arange(len(wcopy)-1)
      try:
          popt, pcov = curve_fit(expfunc, x, diffs)
      except Exception as e:
          print e
          popt = [0.0, 0.0, 0.0]
          pcov = np.inf
  
      # If a &gt; 0.5 and covsum &lt; 1000.0
      # use a logarithmic scale.
      if type(pcov) == float:
          # It's probably np.inf
          covsum = pcov
      else:
          covsum = pcov.diagonal().sum()
      res = (covsum &lt; 1000.0) &amp; (popt[0] &gt; 0.5)
      return res
  </code></pre>
  
  <p>I'm trying to find an alternative to scipy's <code>curve_fit()</code>, because I don't want to install such a big library just to use that one function. Is there something else I can use, or a combination of other functions from using ideally just numpy and matplotlib, to get a similar result?</p>