I have a question about the computation of an expectation.
Consider 3 random variables $Y,X,Z$.
$Y\equiv f(Z)$.
$Z$ is continuous, $Y$ is discrete.
In what follows the notation $1(...)$ denotes the indicator function taking values $1$ if the condition inside is satisfied and $0$ otherwise. Moreover, small case letters denote realisations of random variables.
CASE 1: $X$ is discrete. Let
$$ m^{y,x}(Y,X)\equiv 1(Y=y) 1(X=x) - P(Z \text{ takes a value s.t. } Y=y| X)*1(X=x) $$
Then $$ E\Big[m^{y,x}(Y,X)\Big]=E\Big[1(Y=y) 1(X=x)\Big] - E\Big[P(Z \text{ takes a value s.t. } Y=y| X)*1(X=x)\Big]=P(Y=y, X=x)-P(Z \text{ takes a value s.t. } Y=y| X=x)*P(X=x) $$ $$= P(Y=y, X=x)-P(Z \text{ takes a value s.t. } Y=y, X=x) $$
CASE 2: $X$ is continuous with pdf $g$. Let $K$ be a subset of the support of $X$ such that $P(X\in K)>0$. Let
$$ m^{y,K}(Y,X)\equiv 1(Y=y) 1(X\in K) - P(Z \text{ takes a value s.t. } Y=y| X)*1(X\in K) $$
Then $$ E\Big[m^{y,K}(Y,X)\Big]=E\Big[1(Y=y) 1(X\in K)\Big] - E\Big[P(Z \text{ takes a value s.t. } Y=y| X)*1(X\in K)\Big]=P(Y=y, X\in K)-\int_{K}P(Z \text{ takes a value s.t. } Y=y| X=x)*g(x)dx $$ Question: is it true that $$ \int_{K}P(Z \text{ takes a value s.t. } Y=y| X=x)*g(x)dx= P(Z \text{ takes a value s.t. } Y=y, X\in K) $$
?