Let $Y_1, Y_2, Y_3$ be i.i.d continuous random variables. For $i = 1, 2$ define $U_i$ as
$U_i=1$ if $Y_{i+1} > Y_i,$
$=0$ ,otherwise
Find the mean and variance of $U_1 + U_2$
I can't find the distribution of $U_1 + U_2$.
Let $Y_1, Y_2, Y_3$ be i.i.d continuous random variables. For $i = 1, 2$ define $U_i$ as
$U_i=1$ if $Y_{i+1} > Y_i,$
$=0$ ,otherwise
Find the mean and variance of $U_1 + U_2$
I can't find the distribution of $U_1 + U_2$.
Note that $U_i=1$ if $Y_{i+1} > Y_i$,
$~~~~~~~~~~~~~~~~=0$ ,otherwise
So, $U_i$ $=1$ with prob. $P[Y_{i+1} > Y_i]=\frac{1}{2}$
$~~~~~~~~=0$ with prob. $\frac{1}{2}$
So, $U_1,U_2$~$Ber(\frac{1}{2})$
Let $Z=U_1+U_2$ So, the P.M.F of Z
$f_{Z}(z)=0$ if $(U_1,U_2)=(0,0)$
$~~~~~~~~=1$ if $(U_1,U_2)=(1,0)$ or $(U_1,U_2)=(0,1)$
$~~~~~~~~=2$ if $(U_1,U_2)=(1,1)$
$=>f_{Z}(z)=0$ if $Y_1>Y_2>Y_3$
$~~~~~~~~=1$ if $Y_1<Y_2>Y_3$ or $Y_1>Y_2<Y_3$
$~~~~~~~~=2$ if $Y_1<Y_2<Y_3$
$=>f_{Z}(z)=0$ With prob $P[Y_1>Y_2>Y_3]=1/6$
$~~~~~~~~=1$ With prob $P[Y_1<Y_2>Y_3,Y_1>Y_2<Y_3]=P[Y_2>Y_1>Y_3,Y_2>Y_3>Y_1,Y_2<Y_1<Y_3,Y_2<Y_3<Y_3]=4/6$
$~~~~~~~~=2$ With prob $P[Y_1<Y_2<Y_3]=1/6$
So, Mean=$1.\frac{4}{6}+2\frac{1}{6}=1$ and Variance= $1^2\frac{4}{6}+2^2\frac{1}{6}-1^2=\frac{2}{6}$
R
calculation set.seed(17); var(replicate(100000, sum(diff(runif(3))>0))
, which simulates $U_1+U_2$ exactly as described in the question, returns $0.334\ldots$, demonstrating the variance cannot possibly be $1/2$ and is more likely equal to $1/3$. This approach also reveals an effective strategy for solving the problem: if the distribution of the $Y_i$ isn't supposed to matter, first solve the problem by assuming they have a particularly nice, known distribution, such as a uniform.
$\endgroup$