# Trouble generating custom probability density function

I want to generate random distributed numbers from a uniform distribution ($x$ is a uniform distributed number). The probability density that I want to obtain is:

$$f(y) = \mathcal{N}e^{\beta y}$$

The $\mathcal{N}$ is a normalization constant that ensures that $\mathcal{N}\int_0^\infty f(y)dy=1$.

For doing it, I have to calculate: $\mathcal{N}\int_0^{y} f(y')dy'=x$, which, upon calculating the inverse function to obtain $y$ I get

$$y = \frac{1}{\beta}ln(\frac{\beta*x}{\mathcal{N}}+1)$$

My problem is that when I sample this using numpy, and then plot the histogram for $y$, my histogram has a cut-off around $0.36$. Is it wrong my derivation or is it something that I am missing?

• For instance $\beta=-8.39851811$ and $\mathcal{N}=8.80332017964$ – user2820579 Jan 23 '16 at 0:16
• you need $\int f =1$ - that is $N=-\beta>0$ and $y=\frac 1\beta\log(1-x)$. – A.S. Jan 23 '16 at 0:28
• But the integral is $\frac{\mathcal{N}}{\beta}(e^{\beta y}-1)=x$, so I have a prefactor in $x$, this $\beta/\mathcal{N}$ – user2820579 Jan 23 '16 at 0:58
• Where does $\mathcal{N}\int_0^{y} f(y')dy'=x$ even come from? – A.S. Jan 23 '16 at 1:00
• Because I want to generate random numbers with density $f(y)$ from a uniform distribution, where $x$ is a random variable uniformly distributed. – user2820579 Jan 23 '16 at 1:03