calculate expectation and variance of max for 2 random variables i have following problem,
Random variables X and Y have the joint distribution below, and Z=max{X,Y}.
\begin{array}{c|ccc}
          X\setminus Y & 1 & 2 & 3\\
          \hline
          1 & 0.12 & 0.08 & 0.20\\
          2 & 0.18 & 0.12 & 0.30
        \end{array}
calculate E[Z] and V[Z].
i tried to calculate the expectation through sum of max value for each combination of the 2 variables times probability in the table divided over number of all possible combinations, however i am not getting the correct answer. my question, when both variables are equal, what we should consider the max value and what probability should be used?
 A: $Z=1$ iff $X=Y=1$. $Z=2$ iff $X=1,Y=2$ or $X=2,Y=1$ or $X=2,Y=2$  so $P\{Z=2\}=0.08+0.18+0,12$, $Z=3$ iff $X=3,Y=1$ or $X=3,Y=2$ or $X=1,Y=3$ or $X=2,Y=3$  or $X=Y=3$, so add the probabilities of these. Now you have the distribution of $Z$. Can you take it from here?
A: As shown in the answer of Kavi you can do it by first finding the distribution of $Z$.
On base of that expectations $\mathbb EZ$ and $\mathbb EZ^2$ can be found.
Also you can go for: $$\mathbb EZ=\mathbb E\max\{X,Y\}=\sum_{i=1}^2\sum_{j=1}^3\max\{i,j\}P(X=i,Y=j)$$and $$\mathbb EZ^2=\mathbb E\max\{X,Y\}^2=\sum_{i=1}^2\sum_{j=1}^3\max\{i,j\}^2P(X=i,Y=j)$$
In this case I would go for the method of Kavi, but often this way works more easily.
A: Consider the cumulative distribution function (cdf) of Z 
$F_Z(z)=P(Z<=z)=P[(X<=z \wedge Y<=z)=\int_{-\infty}^z dx \int_{-\infty}^z dy\ P(x,y)$
You deal with discrete random variables with a compactly supported joint density of probablities over the rectangle $[1,2]\times [1,3]$ where the integral can be turned into a discrete sum with discrete steps $\Delta x=\Delta y=1$.  
$F_Z(z) = \int_{-\infty}^z dx \int_{-\infty}^z dy\ P(x,y) = \sum_{i=1}^z \sum_{j=1}^z P(i,j)$
It is now clear that for $z>=3$ $F_Z(z)=1$ and for $z<1$, $F_Z(z)=0$ So you have only two values of the cdf to be calculated,
for $z=1$: $$F_Z(1) = P(1,1)= 0.12$$
for $z=2$: $$F_Z(2) = P(1,1)+P(1,2)+P(2,1)+P(2,2)= 0.50$$
Now you can obtain the probability density function (pdf) of $Z$ by discrete forward differentiating the cumulative distribution $P_Z(i)=F_Z(i)-F_Z(i-1)$ starting with 
$P_Z(z) = 0$ for $z<1$ and $P_Z(z)=0$ for $z>3$.
$$P_Z(1) = 0.12 - 0 = 0.12$$
$$P_Z(2) = 0.50 - 0.12 = 0.38$$
$$P_Z(3) = 1.0  - 0.50 = 0.50$$
From this pdf yo will get the first and second order statistical moments
$E(Z) = \int P_Z(z) z dz = P_Z(1)*1+P_Z(2)*2+P_Z(3)*3 = 0.12+2*0.38+0.5*3=2.38$
$E(Z^2) = \int P_Z(z) z^2 dz = P_Z(1)*1+P_Z(2)*4+P_Z(3)*9=0.12+4*0.38+9*0.5=6.14$
You classically get the variance of $Z$ as,
$V(Z)=E([Z-E(Z)]^2)=E([Z^2-2ZE(Z)+E(Z)^2]=E(Z^2)-E(Z)^2=6.14-2.38*2.38=0.4756$
Hope this helps.
