# Is every measurable function the conditional expectation of some random variable?

Let $$X$$ and $$Y$$ be two random variables defined on the same probability space $$(\Omega,\mathcal F,\mathbb P)$$ and taking value respectively in $$\mathcal X:=[0,1]^d$$ and $$\mathcal Y:=\{-1,+1\}$$. Denote by $$\rho$$ the joint law of $$(X,Y)$$.

Because the conditional expectation $$\mathbb E_{(X,Y)\sim\rho}[Y\mid X]$$ exists, we can consider the map $$\varphi : x\in[0,1]^d \mapsto \mathbb E_{(X,Y)\sim\rho}[Y\mid X=x]$$ which is measurable and $$[-1,1]$$-valued.

My question concerns the converse statement : given a measurable map $$\eta:[0,1]^d\to[-1,1]$$, when does there exist a distribution $$\varrho$$ on $$\mathcal X\times\mathcal Y$$ such that $$\eta(x) = \mathbb E_{(X',Y')\sim\varrho}[Y'\mid X'=x]$$ ? And when it does exist, can it be expressed "explicitly" in terms of $$\eta$$ ?

Consider any probability space $$(\Omega, \mathcal{F}, \mathbb{P})$$ ample enough to host two independent random variables $$X$$ and $$U$$ on it, where

$$X \sim \text{Uniform}(\mathcal{X}) \qquad\text{and}\qquad U \sim \text{Uniform}([-1,1]).$$

Then define $$Y$$ as

$$Y = \mathbf{1}[U \leq \eta(X)] - \mathbf{1}[U > \eta(X)] = \begin{cases} 1, & U \leq \eta(X), \\ -1, & U \geq \eta(X) \end{cases}$$

We claim that $$\mathbb{E}[Y\mid X=x] = \eta(x)$$ for a.e. $$x$$ (with respect to the Lebesgue measure). Indeed, for a.e. $$x$$, we have

\begin{align*} \mathbb{E}[Y \mid X = x] &= \mathbb{E}[ \mathbf{1}[U \leq \eta(X)] - \mathbf{1}[U > \eta(X)] \mid X = x] \\ &= \mathbb{E}[ \mathbf{1}[U \leq \eta(x)] - \mathbf{1}[U > \eta(x)] ] \\ &= \mathbb{P}[U \leq \eta(x)] - \mathbb{P}[U > \eta(x)] \\ &= \tfrac{1}{2}(1+\eta(x)) - \tfrac{1}{2}(1-\eta(x)) \\ &= \eta(x). \end{align*}

• Beautiful ! Just a clarification : correct me if I'm wrong, but it seems that in your construction, $X$ doesn't really need to be uniformly distributed, but could instead follow any distribution on $\mathcal X$. Am I correct ? Jul 14, 2023 at 5:30
• @Stratossupportsthestrike Indeed. You can impose any distribution $\mu$ on $\mathcal{X}$ with $X\sim\mathcal{X}$, and then the same construction tells that the equality will hold in $\mu$-almost-every sense:$$\mathbb{E}[Y\mid X=x]=\eta(x)\qquad\text{for \mu-a.e. x\in\mathcal{X}}$$ I chose the uniform distribution so that the "$\mu$-a.e." part becomes interchangeable with Lebesgue-a.e. sense. Jul 14, 2023 at 9:39
• Wonderful, thank you for this very helpful answer :) Jul 14, 2023 at 11:50