title: numpy histogram cumulative density does not sum to 1
body: <p>Taking a tip from another thread (<a href="https://stackoverflow.com/questions/15408371/cumulative-distribution-plots-python/15419072#15419072">@EnricoGiampieri's answer</a> to <a href="https://stackoverflow.com/questions/15408371/cumulative-distribution-plots-python">cumulative distribution plots python</a>), I wrote:</p>
  
  <pre><code># plot cumulative density function of nearest nbr distances
  # evaluate the histogram
  values, base = np.histogram(nearest, bins=20, density=1)
  #evaluate the cumulative
  cumulative = np.cumsum(values)
  # plot the cumulative function
  plt.plot(base[:-1], cumulative, label='data')
  </code></pre>
  
  <p>I put in the density=1 from the documentation on np.histogram, which says:</p>
  
  <p>"Note that the sum of the histogram values will not be equal to 1 unless bins of unity width are chosen; it is not a probability mass function. "</p>
  
  <p>Well, indeed, when plotted, they don't sum to 1.  But, I do not understand the "bins of unity width."  When I set the bins to 1, of course, I get an empty chart; when I set them to the population size, I don't get a sum to 1 (more like 0.2).  When I use the 40 bins suggested, they sum to about .006.</p>
  
  <p>Can anybody give me some guidance?  Thanks!</p>