# Inverse transformation sampling: Logistic CDF

We have a generator $$X$$ that selects numbers from a uniform distribution on $$(0,1)$$ denoted $$\text{Unif}(0,1)$$.

We have to show how it can be used with the function $$x \mapsto \log\left(\frac{x}{1-x}\right)$$ to generate a random number from a distribution with cumulative distribution function $$F(x)=\frac{e^x}{1+e^x}$$.

The calculation required is to verify that $$F^{-1}\left(X\right)$$ has cumulative distribution function $$F$$.

I try it this way:

Let random variable $$X \sim \text{Unif}(0,1)$$.

$$P\left(\log\left(\frac{X}{1-X}\right)\le x\right)=P\left(\frac{X}{1-X}\le e^x\right)=P\left(X\le \frac{e^x}{1+e^x}\right)$$.

I think that this is the way but I don't know how to continue and how to justify that:

$$P\left(X\le \frac{e^x}{1+e^x}\right)=\frac{e^x}{1+e^x}$$.

• The last step is true because $X$ is uniform on $[0,1]$: $P(X \leq u) = u$
We have $$X \sim \text{Unif}(0,1)$$, $$Y \sim F$$, where $$F(x) = \frac{e^x}{1+e^x}$$.
We want to show that $$F^{-1}(X)$$ has the same distribution as $$Y$$. In other words, we must verify that \begin{align*} \mathbb{P}(F^{-1}(X) \leq y) = \mathbb{P}(Y \leq y) = F(y). \end{align*} By straightforward calculations we find that $$F^{-1}(x) = \log\big(\frac{x}{1-x}\big)$$. Thus \begin{align*} \mathbb{P}(F^{-1}(X) \leq y) &= \mathbb{P}\!\left(\log\left(\frac{X}{X-1}\right) \leq y \right) \\ &= \mathbb{P}\left(X \leq \frac{e^y}{1+e^y}\right) \\ &= \frac{e^y}{1+e^y} = F(y), \end{align*} as desired. We have used that $$\mathbb{P}(X \leq x) = x$$ for $$x\in(0,1)$$. This holds since $$X \sim \text{Unif}(0,1)$$.