title: Calculating the derivative of cumulative density function in Python
body: <p>Is it the case that the exact derivative of a cumulative density function is the probability density function (PDF)?  I am calculating the derivative using the <code>numpy.diff()</code>, is this correct? See below code below:</p>
  
  <pre><code>import scipy.stats as s
  import matplotlib.pyplot as plt
  import numpy as np
  
  wei = s.weibull_min(2, 0, 2) # shape, loc, scale - creates weibull object
  sample = wei.rvs(1000)
  shape, loc, scale = s.weibull_min.fit(sample, floc=0) 
  
  x = np.linspace(np.min(sample), np.max(sample))
  
  plt.hist(sample, normed=True, fc="none", ec="grey", label="frequency")
  plt.plot(x, wei.cdf(x), label="cdf")
  plt.plot(x, wei.pdf(x), label="pdf")
  plt.plot(x[1:], np.diff(wei.cdf(x)), label="derivative")
  plt.legend(loc=1)
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/OKT9E.png" alt="Compariosn of CDF, PDF and derivative"></p>
  
  <p>If so, how do I scale the derivative to be equivalent to the PDF?</p>