Generalization of inverse transform sampling If X is a random variable over an arbitrary alphabet, is there a (deterministic) function f() such that X = f(U), where U is a uniform random variable over the unit-interval?
 A: The answer is in general no. More specifically, if the random variable (r.v.) $X$ is defined on a discrete probability space, then any r.v. $U$ defined on that same probability space must be discrete and hence cannot be uniformly distributed on the unit interval. 
However, for any r.v. $X$ whatsoever there is a function $f$ such that the r.v. $f(U)$ will equal $X$ in distribution, where $U$ is any r.v. uniformly distributed on the unit interval. In particular, one may take $f=F^{-1}$, where 
\begin{equation}
 F^{-1}(u):=\inf\{x\in\mathbb R\colon F(x)\ge u\}
\end{equation}
for $u\in(0,1)$, where $F(x):=P(X\le x)$. See e.g. formulas (4.1) and (6.7). 
In particular, if $X$ is a discrete r.v. taking values $x_1,x_2,\dots$ with the corresponding probabilities $p_1,p_2,\dots$ (such that $p_1+p_2+\cdots=1$), then one may take $f$ defined by the formula 
$f(u)=x_j$ for $u\in[u_{j-1},u_j)$, where $j=1,2,\dots$, $u_0:=0$, and $u_j:=p_1+\dots+p_j$ for $j\ge1$ -- with the effect that $f(U)$ equals $X$ in distribution, where, again, $U$ is any r.v. uniformly distributed on the unit interval. 
