= Solution
Integration of the <Laplace distribution> <probability density function> gives
$$
F(x)=\begin{cases}\tfrac12e^{(x-1)/2},&x\leq1,\\1-\tfrac12e^{-(x-1)/2},&x\geq1.\end{cases}
$$
Solving these two equations for $x$ gives
$$
\boxed{F^{-1}(u)=\begin{cases}1+2\log(2u),&0<u\leq\tfrac12,\\1-2\log(2(1-u)),&\tfrac12<u<1.\end{cases}}
$$
Generate one uniform $U\in(0,1)$ and return this piecewise expression. The branches agree at $U=1/2$ and the <inverse transform sampling> proof establishes the target law without any rejection step.
Back to article page