Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am slightly confused about the different between

$\mathrm{E}[Y|X = x]$



and similarly for Variance.

It seems to me the first should be a scalar, because we first pick a specific $X = x$ and then get the expected value of $Y$ within that set whereas the second one is a random variable that depends on the random variable $X$. Is that correct?

Any definition using the probabilities $\mathrm{P}(X)$, $\mathrm{P}(Y)$, $\mathrm{P}(Y|X)$ and $\mathrm{P}(Y, X)$ is appreciated.

share|cite|improve this question
Your interpretation is correct. $\Bbb E[Y|X]$ is a random variable whose value at $X=x$ is $\Bbb E[Y|X=x]$. $\Bbb E[Y|X]$ is called the conditional expectation of $Y$ given $X$. A similar statement holds for the conditional variance of $Y$ given $X$ (symbolized by $\text{Var}[Y|X]$). – David Mitra Feb 19 '12 at 17:10
You need to be clear whether $X$ and $Y$ are random variables or events. If they are random variables then $E[Y|X]$ may be a function of a random variable and so a random variable, but then so too is $P(X)$ which may not be what you intend as you describe it as a probability. – Henry Feb 19 '12 at 21:36

Your surmise is correct.

Let's say with probability $1/2$ I pick a biased coin, and toss it, getting $Y=1$ with probability $1/3$ and $Y=0$ with probability $2/3$. And with probability $1/2$ I pick an unbiased coin. Let $X$ be $0$ or $1$ according as I pick the biased or unbiased coin. Then $$ \begin{align} E(Y \mid X=0) & = \frac 1 3 \\ \\ E(Y \mid X=1) & = \frac 1 2 \\ \\ \\ E(Y \mid X) & = \begin{cases} \frac 1 3 & \text{with probability }1/2, \\ \\ \frac 1 2 & \text{with probability }1/2. \end{cases} \end{align} $$ And similarly for conditional variances.

Having done that, one can write things like $$ E(E(Y \mid X)) = E(Y) $$ (the law of total expectation) and $$ E(\operatorname{var}(Y \mid X)) + \operatorname{var}(E(Y \mid X)) = \operatorname{var}(Y) $$ (the law of total variance, which breaks the variance into an "explained" part and an "unexplained" part). (Now I notice that I wrote the "unexplained" part first, so don't add "respectively".)

In a similar way, one has $$ E(\Pr(A \mid X)) = \Pr(A) $$ (the law of total probability).

share|cite|improve this answer
In words, the variance of $Y$ is $E[\text{var}(Y|X)]$, the mean of the conditional variance plus $\text{var}(E[Y|X])$, the variance of the conditional mean. – Dilip Sarwate Feb 19 '12 at 23:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.