title: How to generate random numbers with predefined probability distribution?
body: <p>I would like to implement a function in python (using <code>numpy</code>) that takes a mathematical function (for ex. <code>p(x) = e^(-x)</code> like below) as input and generates random numbers, that are distributed according to that mathematical-function's probability distribution. And I need to plot them, so we can see the distribution. </p>
  
  <p>I need actually exactly a random number generator function for exactly the following 2 mathematical functions as input, but if it could take other functions, why not: </p>
  
  <p>1) <code>p(x) = e^(-x)</code><br>
  2) <code>g(x) = (1/sqrt(2*pi)) * e^(-(x^2)/2)</code></p>
  
  <p>Does anyone have any idea how this is doable in python? </p>