# Why is conditional probability a random variable?

Let $(\Omega, \mathcal{F}, P)$ be a probability space and $X$ be a random variable from $(\Omega, \mathcal{F})$ to $(\mathbb{R}, \mathcal{B})$. Let $\mathcal{T} \subset \mathcal{F}$ be another sigma algebra. Is $P(X \in B| \mathcal{T})$ a random variable for fixed $B \in \mathcal{B}$? If so, what is its domain and range? It would be great if someone can explain in detail.

I must let you down if it comes to an explanation in detail, but cannot withhold myself from sharing these thoughts:

$P(X\in B)=\mathbb E1_B(X)$ where $1_B(X)$ is a random variable taking values in $\{0,1\}$.

In that line $P(X\in B\mid\mathcal T)=\mathbb E(1_B(X)\mid\mathcal T)$.

Special case: $P(X\in B\mid\mathcal F)=1_B(X)$.

Let $\Omega = \{1,\dotsc,6\}$, the various outcomes of the roll of a single dice. Let $\mathcal{F} = 2^{\Omega}$, the power set of $\Omega$ and $P(w) = \frac{1}{6}, \forall \omega \in \Omega$. Clearly, $(\Omega, \mathcal{F}, P)$ defines a probability space.

Let $B = \{1,3,4\}$. Let $\mathcal{T}_1$ be the $\sigma$-algebra generated by the sets $\{1,3,5\}$ and $\{2,4,6\}$. Our aim is to compute $P(B| \mathcal{T}_1)$.

We will make use of two facts:

1) The probability of a set $B$ is the expectation of the indicator random variable $1_B$.

2) The conditional expectation of a random variable $X$ with respect to a $\sigma$-algebra $\mathcal{T}_1$ is the unique $\mathcal{T}_1$ measurable random variable that is 'closest' to $X$.

$$\mathrm{E}[X|\mathcal{T}_1] = \arg \inf_{Y\, is \,\mathcal{T}_1 \,\text{measurable}} \mathrm{E}(X-Y)^2$$

But how do $\mathcal{T}_1$ measurable random variables look like? We answer the above question using two lemmas.

Lemma 1: If $\Omega$ is countable, for every $\sigma$-algebra $\mathcal{T}$, there exists a unique partition of $\Omega$ that generate $\mathcal{T}$.

(The proof is easily seen by defining a partial order in $\mathcal{T}$ 'subset of')

Lemma 2: Let $\mathcal{P}$ be the unique partition that generates $\mathcal{T}$. Then, every $\mathcal{T}$ measurable random variable can be written as $\sum_{A \in \mathcal{P}} c_A 1_{A}, \, c_A \in \mathbb{R}$.

What this means is the following. If $Y$ is $\mathcal{T}$-measurable random variable, then $Y(\omega) = Y(\omega')$ if $\omega$ and $\omega'$ lie in the same equivalence class defined by the partition $\mathcal{P}$.

Coming back to our original problem, the partition $\mathcal{P}$ is given as $\{\{1,3,5\}, \{2,4,6\}\}$. Hence, any $\mathcal{T}_1$ measurable random variable is given by $c_1 1_{\{1,3,5\}} + c_2 1_{\{2,4,6\}}$. In order to compute the conditional probability distribution $P(B|\mathcal{T}_1)$, we need to project the indicator random variable $1_B$ on $\mathcal{T}_1$. The distance between $1_B$ and any $\mathcal{T}_1$ measurable random variable is given by $$\frac{1}{6}[(c_1-1)^2 + (c_2-0)^2 + (c_1-1)^2 + (c_2-1)^2 + (c_1-0)^2 + (c_2-0)^2]$$

The above equation is minimized when $c_1=\frac{2}{3}$ and $c_2 = \frac{1}{3}$.

Hence, $$P(B|\mathcal{T}_1)(\omega) = \frac{2}{3} 1_{\{1,3,5\}}(\omega) + \frac{1}{3} 1_{\{2,4,6\}}(\omega),\, \omega \in \Omega$$

Hence, it is a random variable from $(\Omega, \mathcal{T}_1)$ to $(\mathbb{R}, \mathcal{B})$. In words, what the above equation means is that if we know that the output of the dice is odd, the probability of $B$ is $\frac{2}{3}$. However, if we know that the output of the dice is even, then the probability of $B$ is $\frac{1}{3}$.

If $\mathcal{T}_2$ is the $\sigma$-algebra generated by the partiton $\mathcal{P} = \{\{1,2\}, \{3,4\}, \{5,6\}\}$. Then any $\mathcal{T}_2$ mesurable random variable is given by $c_1 1_{\{1,2\}}+ c_2 1_{\{3,4\}} +c_3 1_{\{5,6\}}$. The distance between $1_B$ and a $\mathcal{T}_2$ measurable random variable is given by

$$\frac{1}{6}[(c_1-1)^2 + (c_1-0)^2 + (c_2-1)^2 + (c_2-1)^2 + (c_3-0)^2 + (c_3-0)^2]$$ The above equation is minimized when $c_1=\frac{1}{2},\, c_2 = 1$ and $c_3 = 0$. Hence, the conditional distribution is given by

$$P(B|\mathcal{T}_2) = \frac{1}{2}. 1_{\{1,2\}} + 1. 1_{\{3,4\}} + 0. 1_{\{5,6\}}$$ which is a random variable from $(\Omega, \mathcal{T}_2)$ to $(\mathbb{R}, \mathcal{B})$. In words, the above equation means that if we know that the output of the dice lies in the set $\{1,2\}$, then probability of $B$ is $\frac{1}{2}$, and so on...