What is the explanation of this expected value result? Given $X \sim Uni(0,1)$, and $Z = \mathbb{I} \{a < x < 1\}$, $Y = \mathbb{I} \{0 < x < b\}$
for the parameters $0 < a < b < 1$. And we know that $Y$ and $Z$ are dependent.
So basically what I can understand from this, is that $Z = 1$ if $a < x < 1$, otherwise $Z = 0$.
And the same for $Y$, as $Y = 1$ if $0 < x < b$, otherwise $Y = 0$
I need to find $E[Y|Z]$. The answer for this is the following, although I don't understand almost anything out of it:
For $Z = 1$:
$$P(y = 0|z = 1) = \frac{P(y = 0, z = 1)}{P(z = 1)} = \frac{1-b}{1-a}$$
$$P(y = 1|z = 1) = \frac{P(y = 1, z = 1)}{P(z = 1)} = \frac{b-a}{1-a}$$
$$P(Z = 1) = 1-a$$
for $Z = 0$:
$$P(y = 0|z = 0) = \frac{P(y = 1, z = 0)}{P(z = 0)} = \frac{a}{a} = 1$$
$$P(Z = 0) = a$$
Finally:
$$E[Y|Z] = E[Y|Z = z] * P(Z = z) = P(Y = 1| Z = 1) * P(Z = 1) + P(Y = 1|Z = 0)*P(Z = 0) = \frac{b-a}{1-a} a + 1 (1-a)$$
Can someone please help me understand how did we get to the final formula? why is $P(y = 0, z = 1) = 1 - b$  and why is $P(z = 1) = 1 - a$ ?
N

Answering the final questions out of order:
Let $f(x)=1$ be the density of $X \sim Uniform(0,1)$
$$P(Z = 1) = \int_a^1 f(x)dx = \int_a^1 1dx = 1 -a$$
$$P(y = 0, z = 1) = P(y = 0 | z =1) P(z=1) = \frac{1-b}{1-a}(1-a) = 1 - b$$
By the meaning of conditional expectation (I think there was a mistake in the notation)
$$E(Y) = \sum_z E[Y|Z = z] P(Z = z)$$
By the meaning of the expected value
$$E[Y|Z=z] = \sum_y yP(Y=y|Z=z) = (1) P(Y = 1|Z = z) + (0) P(Y=0|Z=z)$$
Now
$$E(Y) = P(Y = 1|Z = 0) P(Z=0) + P(Y=1|Z=1)P(Z=1)$$
$$ = (1)(a) + \frac{b-a}{1-a} (1-a) = b$$
Also
$$E(Y|Z=0) = P(Y = 1|Z = 0) = 1$$
$$E(Y|Z=1) = P(Y = 1|Z = 1) = \frac{b-a}{1 - a}$$
You can simulate these in R
X <- runif(100000)

a <- 0.5
b <- 0.7

Y <- ifelse(X < b, 1, 0)
Z <- ifelse(X > a, 1, 0)

mean(Y)
b
mean(Y[Z == 0])
1
mean(Y[Z == 1])
(b-a) / (1-a)

