# How does $E(u)=\int E(u|v)p(v)dv$?

I'm reading Bayesian Data Analysis: http://www.stat.columbia.edu/~gelman/book/ and this equation was given

$$E(u)=\int E(u|v)p(v)dv$$

Can someone explain this to me? I don't see how they're equivalent, because to get the expectation of $$u$$ you need to get the average of $$u$$, but the RHS is the integral across all $$v$$, but then there could be values of $$u$$ not conditioned on $$v$$ so that means those values will be excluded will they not? Which means it's not the expectation for $$u$$ because it's not the weighted sum across all $$u$$.

It's the simpler form of Law of Total Expectation, $$E[u]=E[E[u|v]]$$. The inside expression is a function of $$v$$, so it's like $$E[u|v]=g(v)$$, and we want $$E[g(v)]$$, which is $$E[u]=E[g(v)]=\int g(v)p(v)dv=\int E[u|v]p(v)dv$$
• I don't think they made it clear in the book but I'm guessing $v$ is a set of sets that at independent and together make up the entire space? If that's the case then that totally make sense. – user8714896 Feb 1 at 0:24
• $v$ is another random variable, and we integrate over its all possibilities. – gunes Feb 1 at 13:39