The density of my points x ∈ [0,R] is exponential: ρ(x)~e^x How can I sample N points from there?
Taking your request at face value, if you want a density function that grows exponentially for x ∈ [0,R] the cumulative distribution function turns out to be (exp(x) - 1) / (exp(R) - 1)
. To generate this via inversion, set the CDF equal to a Uniform(0,1)
and solve for x
. The inversion turns out to be:
ln(1 + (exp(R) - 1) * U)
where U represents a call to the Uniform(0,1) PRNG.
If what you actually want is a truncated form of what most probability folks know as the exponential distribution, we need to determine an upper bound for the random number corresponding to your truncation point R
. In that case, the inversion is:
-ln(1 - [1 - exp(-lambda * R)] * U) / lambda
As before, U represents a call to the Uniform(0,1) PRNG. This will generate exponentials at rate lambda
, truncated at a max of R
.