<s>[INST] How can I find the expectation and variance of $Z=\max\{X,Y\}$ where $X$ and $Y$ are defined through joint probability distribution? Random variables $X$ and $Y$ and  have the joint distribution below, and $Z=\max\{X,Y\}$
$$
\begin{array}{c|lcr}
\text{X\Y} & \text{1} & \text{2} & \text{3} \\
\hline
1 & 0.12 & 0.08 & 0.20 \\
2 & 0.18 & 0.12 & 0.30 \\
\end{array}
$$ 
Find $E[Z]$ and $V[Z]$ 
I am unable to understand that if $Z=\max\{X,Y\}$ then how will we take the pairs? Or just $Y=3$ ? Because it is the only maximum. Please explain I am just stuck here.
 [/INST] If $Z = \max(X, Y)$, then the following is true:
$Z = 1$ iff $X = 1$ and $Y = 1$.
$Z = 2$ iff either $X = 1$ and $Y =2$ or $X = 2$ and $Y = 1$, or $X = 2$ and $Y = 2$.
$Z = 3$ iff $X = 3$. 
So $P(Z = 1) = 0.12$
$P(Z = 2) = 0.08 + 0.12 + 0.18 = 0.38$
$P(Z = 3) = 0.2 + 0.3 = 0.5$. 
Thus $E(Z) = 0.12 + 2*0.38 + 3*0.5 = 0.12 + 0.76 + 1.5 = 2.38$
$E(Z^2) = 0.12 + 4*0.38 + 9*0.5 = 0.12 + 1.52+ 4.5 = 6.04$
That means $V(Z) = E(Z^2) - (E(Z))^2 = 6.04 - 5.6644 = 0.3756$.
</s>