I'm still stuck on conditional expectation. Let $ X: (\Omega,\mathscr{F},P) \mapsto (\mathbb{R},\mathcal{B}(\mathbb{R}))$ be an integrable random variable. $\mathscr{G}$ is a sub-$\sigma$-field of $\mathscr{F}$, and $G \in \mathscr{G}$ is an event. I can't explain the difference between the following two formulas: $$ \int_{G}\mathbb{E}(X|\mathscr{G})\mathrm {d}P, \qquad(1) $$ $$ \mathbb{E}(X|G).\qquad(2) $$
For example, let $Y$ be a random variable on $(\Omega,\mathscr{F},P)$ and $\mathscr{G}=\sigma(Y)$. Let $$ P(X=1,Y=1)=P(X=1,Y=0)=P(X=0,Y=1)=P(X=0,Y=0)=1/4. $$ Let $G=Y^{-1}(\{1\})$, that is the preimage of $Y=1$. Then by definition, $$ \int_G\mathbb{E}(X|\mathscr{G})\mathrm{d}P=\int_G X \mathrm{d}P= 1 \times\frac 1 4+ 0 \times \frac 1 4 = 1/4,\qquad (3) $$ $$ \mathbb{E}(X|G)=1\times\frac{1/4}{1/2}+0\times\frac{1/4}{1/2} = 1/2.\qquad(4) $$ I can't understand why they are different. Any related resources will be appreciated. Thanks!
Recall that by definition of conditional expectation
$$ \int_{G} \mathbb{E}(X|\mathscr{G})dP = \int \mathbb{E}(X|\mathscr{G}) 1_{G} dP = \int X 1_{G} dP = \int_{G} X dP $$
since $1_G$ is measurable w.r.t. $\mathscr{G}$.
On the other hand, the expression $\mathbb{E}[X|G]$ is defined as
$$ \int X dP(\cdot|G) = \frac{1}{P(G)} \int X 1_G dP = \frac{1}{P(G)} \int_G X dP $$
where $P(\cdot|G)$ is the probability measure on $(\Omega,\mathscr{F})$ defined by $P(A|G) = \frac{P(A \cap G)}{P(G)}$.
Hence, in your example, your two solutions differ exactly be the inverse of the measure of $G$, which in your case is $\frac{1}{2}$.