title: How do I calculate PDF (probability density function) in Python?
body: <p>I have the following code below that prints the PDF graph for a particular mean and standard deviation.</p>
  
  <p><a href="https://imgur.com/a/oVgML" rel="noreferrer">http://imgur.com/a/oVgML</a></p>
  
  <p>Now I need to find the actual probability, of a particular value. So for example if my mean is 0, and my value is 0, my probability is 1. This is usually done by calculating the area under the curve. Similar to this:</p>
  
  <p><a href="http://homepage.divms.uiowa.edu/~mbognar/applets/normal.html" rel="noreferrer">http://homepage.divms.uiowa.edu/~mbognar/applets/normal.html</a></p>
  
  <p>I am not sure how to approach this problem</p>
  
  <pre><code>import numpy as np
  import matplotlib    
  import matplotlib.pyplot as plt
  
  def normal(power, mean, std, val):
      a = 1/(np.sqrt(2*np.pi)*std)
      diff = np.abs(np.power(val-mean, power))
      b = np.exp(-(diff)/(2*std*std))
      return a*b
  
  pdf_array = []
  array = np.arange(-2,2,0.1)
  print array
  for i in array:
      print i
      pdf = normal(2, 0, 0.1, i)
      print pdf
      pdf_array.append(pdf)
  
  plt.plot(array, pdf_array)
  plt.ylabel('some numbers')
  plt.axis([-2, 2, 0, 5])
  plt.show()
  
  print 
  </code></pre>