title: Derivative of log plot in python
body: <p>We have the <code>x</code> and <code>y</code> values, and I am taking their log, by <code>logx = np.log10(x)</code> and <code>logy = np.log10(y)</code>. I am trying to compute the derivative of logy w.r.t logx, so dlogy/dlogx. I used to do this successfully using numpy gradient, more precisely </p>
  
  <p><code>derivy = np.gradient(logy,np.gradient(logx))</code> </p>
  
  <p>but for some strange reason it doesn't seem to work anymore yielding the error: <code>"Traceback (most recent call last):
    File "derivlog.py", line 79, in &lt;module&gt;
      grady = np.gradient(logy,np.gradient(logx))
    File "/usr/lib/python2.7/dist-packages/numpy/lib/function_base.py", line 1598, in gradient
      raise ValueError("distances must be scalars")
  ValueError: distances must be scalars"</code></p>
  
  <p><strong>Context:</strong> When trying to detect power-laws, of the kind <code>y ~ x^t,</code> given the values of <code>y</code> as a function of <code>x,</code> one wants to exctract essentially the power <code>t,</code> so we take logs which gives <code>log y ~ t*log x</code> and then take the derivative in order to extract <code>t.</code></p>
  
  <p>Here's a minimal example for recreating the problem: <code>x=[  3.   4.   5.   6.   7.   8.   9.  10.  11.]</code></p>
  
  <p><code>y = [ 1.05654  1.44989  1.7939   2.19024  2.62387  3.01583  3.32106  3.51618
    3.68153]</code></p>
  
  <p>Are there other (more suited) methods in python for taking such numerical derivatives?</p>