The conditional expectation of X given Y=y, E[X∣Y=y]=x∑xp(X=x∣Y=y)
E[g(X)∣Y=y]=x∑g(x)p(X=x∣Y=y)
Continuous case:
E[X∣Y=y]=∫−∞∞x.fX∣Y(x∣y)dx
where fX∣Y(x∣y)=fY(y)f(x,y) as in Conditional joint distribution
E[g(X)∣Y=y]=∫−∞∞g(x).fX∣Y(x∣y)dx
E[i=1∑n[xi∣Y=y]]=i=1∑nE[Xi∣Y=y]
Think of E[X∣Y] is itself a random variable. E[X]=E[E[X∣Y]] meaning:
For discrete: E[X]=y∑E[X∣Y=y].P(Y=y)
To calculate E[X], we may take a weighted average of the conditional expected value of X given that Y=y, each of the terms E[X∣Y=y] being weighted by the probability of the event on which it is conditioned.