# Find the mean and variance 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$.

-
It is not necessary to find the distribution of $U_1+U_2$ in order to find the mean and variance of $U_1+U_2$; you can use what is sometimes called the Law of the Unconscious Statistician. But in this case, finding the distribution of $U_1+U_2$ is easy if you work from basics instead of searching your book for a formula to apply. Consider that all $3! = 6$ orderings of the values of $Y_1,Y_2,Y_3$ are equally likely, and work out the values of $U_1+U_2$ that these orderings give, and you have the distribution of $U_1+U_2$. –  Dilip Sarwate Aug 9 '12 at 13:29
In this case though the distribution can be determined. –  Michael Chernick Aug 9 '12 at 14:13
One way to make progress is explicitly to determine the joint distribution of $(U_1,U_2)$ and use that to compute the statistics. The assumptions imply all $3!=6$ permutations of the $Y_i$ are equally likely. From this we find the probabilities of $(U_1,U_2)=(0,0)$ and $(U_1,U_2)=(1,1)$ are both $1/6$ and the probabilities of the other two cases, $(0,1)$ and $(1,0)$, are each $2/6$, because each corresponds to two possible permutations. (This is the crucial step.) From this you should have no trouble finding the distribution of $U_1+U_2$. –  whuber Aug 9 '12 at 18:40

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}$

-
If $U_1$ and $U_2$ are dependent Bernoulli random variables with parameter $\frac{1}{2}$, then the conclusion that $U_1+U_2$ is a binomial $(2,\frac{1}{2})$ random variable is suspect. How do you know that $U_1$ and $U_2$ are independent? In particular, does the event $\{(U_1,U_2) = (1,1)\} = \{Y_1 < Y_2 < Y_3\}$ have probability $\frac{1}{4} = P\{U_1 = 1\}P\{U_2 = 1\}$? I would have thought that the event $\{Y_1 < Y_2 < Y_3\}$ would have probability $\frac{1}{6}$ since all $3!$ orderings of the three random variables should be equally likely from the symmetry of the problem. –  Dilip Sarwate Aug 9 '12 at 13:18
+1 to Dilip. One can refine one's intuition about such things with a quick simulation. E.g., the 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. –  whuber Aug 9 '12 at 13:25
@DilipSarwate: You are right. If $U_1$ and $U_2$ are independent Bernoulli random variables with parameter $1/2$, then $U_1+U_2$ is a binomial $(2,1/2)$.I am not caring the independent fact.Thank you. –  Argha Aug 9 '12 at 13:52
@Ranabir Your revised approach is correct. To get the distribution, mean and variance of U1+U2 you just need to properly express all the possible orderings of Y1, Y2 and Y3 and see what that implies about the values of U1 and U2. I think all the downvotes should now be removed based on the revised answer and people should now consider giving upvotes. –  Michael Chernick Aug 9 '12 at 14:32