finding the inverse of the exponential CDF

40 Views Asked by At

I'm trying to find the inverse transform of the exponential CDF to sample from it (make x the subject of the equation)

see the examples section of https://en.wikipedia.org/wiki/Inverse_transform_sampling

Attempt 1:

$$ y=1-e^{-\lambda x} $$

$$ 1-y = e^{-\lambda x} $$

$$ log(1-y) = -\lambda x $$

$$ x = -log(1-y)/\lambda $$

Attempt 2:

$$ y=1-e^{-\lambda x} $$

$$ y-1 = -e^{-\lambda x} $$

$$ log(y-1) = \lambda x $$

$$ x = log(y-1)/\lambda $$

question: Is $ -log(1-y)/\lambda \equiv log(y-1)/\lambda $

If not, what have I done wrong?