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?

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.