Properties of the expected value rule & total expectation theorem I am going through some T/F questions that test my understanding of the expected value rule and total expectation theorem.
Assume that $X, Y, Z$ are continuous random variables and that all conditional PDFs and expectations are well-defined.

*

*$E[g(y)|X=x]=\int g(y)f_{Y|X}(y|x)dy$
The explanation to this problem says that "the quantity inside the expectation, $g(y)$, is a number (not a random variable). The left-hand side is a function of $y$, whereas on the right-hand side, $y$, is a dummy variable that gets integrated away. So, the formula is wrong on a purely syntactical basis.


*$E[g(X, Z)|Y=y]=\int g(x, z)f_{X,Z|Y}(x,z|y)dy$
The explanation says that "the left-hand side is a function of $y$, whereas the right-hand side (after $y$ is integrated out) is a function of $x$ and $z$. The correct form is:
$$E[g(X, Z)|Y=y]=\int\int g(x, z)f_{X,Z|Y}(x,z|y)dxdz."$$
What I don't understand
For question 1, how does the LHS depend on y while the RHS does not? The explanation says $g(y)$ on the LHS is a number (a constant), so we don't have any dependence on y and yet the explanation says LHS is dependent on y.
For question 2, how does the LHS depend on y? There's no $Y$ in $g(X,Z)$.
 A: In standard notation in stochastics $X, Y$ and so on represent random variables. Random variables are actually functions from a probability space to a measurable space. $x, y$ and so on usually represent just (deterministic) variables, e.g. real numbers.
The expected value of a real number is just that real number, so $\mathrm E[f(x)] = f(x)$ for every real function $f$ and real variable $x$. Clearly this is a function of $x$. The term "constant" in this situation can be misleading because $f(x)$ is in general not constant with respect to changes in the input variable $x$, but it is constant with respect to what happens in our underlying probability space. Hence it is a constant random variable.
In an integral like $\int f(x) \mathrm dx$ the variable $x$ is bound by the integral operator. No matter the value of that integral, it can't depend on $x$. See here for a more thorough explanation.
As for problem 2: $\mathrm E[X|Y=y]$ is the conditional expected value of the random variable $X$ given that the random variable $Y$ takes the value $y$. This expression only makes sense if the event that $Y=y$ has positive probability, so $Y$ should be a discrete random varible. Then we have
$$\mathrm E[X|Y=y] = \int x \mathrm P(X=x|Y=y) \mathrm dx$$ which in the case that $X$ is also a discrete random variable (taking values in $\mathbb N$) is equal to
$$\sum_{x\in\mathbb N} x \frac{P(X=y,Y=y)}{\mathrm P(Y=y)} $$
which is clearly dependent on $y$ because $y$ is a free variable.
