Solution (source code)

= Solution

The generalized <quantile function> is
$$
\boxed{F^{-1}(u)=\inf\{x\in\mathbb R:F(x)\geq u\},\qquad0<u<1.}
$$
The tail limits of a <cumulative distribution function> make the defining set nonempty and its infimum finite. Monotonicity and right continuity imply $F^{-1}(u)\leq x$ exactly when $u\leq F(x)$. To see the direction involving the infimum, let points in the defining set decrease towards it; right continuity gives $F(F^{-1}(u))\geq u$, so every larger $x$ also qualifies. Consequently, for a <uniform distribution> variable $U$,
$$
\mathbb P(F^{-1}(U)\leq x)=\mathbb P(U\leq F(x))=F(x).
$$
The probability-zero endpoints $U=0,1$ can be assigned arbitrary outputs. This proves <inverse transform sampling> even for distributions with atoms or flat portions; continuity or strict monotonicity of $F$ is not required.