How to calculate expectation of product of random variables

993 Views Asked by At

Let $X\sim U(1,n)$ and $Y\sim U(1,n)$ be two discrete random variables that distributes uniformly between $1$ and $n$. (I also have a joint distribution table of $\mathbb{P}_{X,Y}(X,Y))$.

I need to find $Cov(X,Y)$.

This is my work so far:
For simplicity, let $E(X)=\mu _x$, and $E(Y)=\mu _y$.
So, by definition:

$Cov(X,Y)=E[(X-\mu_x)(Y-\mu_y)]=E[XY-X\mu_y-Y\mu_x+\mu_x\mu_y]=$
$E(XY)-\mu_x\mu_y-\mu_x\mu_y+\mu_x\mu_y=E(XY)-\mu_x\mu_y$

and then: $\sum_{1\leq i,j\leq n}x_iy_j\mathbb{P(X=x_i,Y=y_j)}-\mu_x\mu_y$

But how can I calculate this sum? I'm not so sure about it, but do I sum every single value in the joint distribution table and multiply it by it's corresponding probability?