(i) Let $X$ be a random variable on a probability space $(\Omega, \mathcal{F}, \mathbb{P})$, and let $W$ be a nonnegative $\sigma(X)$-measurable random variable. Show there exists a function $g$ such that $W=g(X)$. (Hint: Recall that every set in $\sigma(X)$ is of the form $\{X \in B\}$ for some Borel set $B \subset \mathbb{R}$. Suppose first that $W$ is the indicator of such a set, and then use the standard machine.)
(ii) Let $X$ be a random variable on a probability space $(\Omega, \mathcal{F}, \mathbb{P})$, and let $Y$ be a nonnegative random variable on this space. We do not assume that $X$ and $Y$ have a joint density. Nonetheless, show there is a function $g$ such that $\mathbb{E}[Y \mid X]=g(X)$.