Lets say I am given the following table that shows the joint probability function of X and Y:
$$\begin{array}
\\{}&y=1&y=2&y=3
\\x_=1&0.1&0.2&0.1
\\x=2&0.1&0.25&0.15
\\x=3&0&0&0.1
\end{array}$$
Then I am fairly sure the marginal probability functions of $X$ and $Y$ are given by their totals across each row and column, eg:
$$\begin{array}
\\{}&y=1&y=2&y=3&P_X(X)
\\x=1&0.1&0.2&0.1&0.4
\\x=2&0.1&0.25&0.15&0.5
\\x=3&0&0&0.1&0.1
\\P_Y(Y)&0.2&0.45&0.35&1
\end{array}$$
I want to workout $$E(X),E(Y),Var(X),Var(Y),Cov(X,Y)$$
Now I assume that E(X) comes from P(X) here, so I get $ 0.4*1 + 0.5 * 2 + 0.1 * 3=1.7$
E(Y) same procedure $= 2.15$
Var(X) = $ 0.4*1^2 + 0.5 * 2^2 + 0.1 * 3^2 – 1.7^2 = .41$
Var(Y) same procedure = .5275
Cov(X,Y) I am not sure how to calculate this really. Is any of the above wrong? Any hints on solving Cov(X,Y)? Thank you for your time, and I am sorry about any bad latex formatting, this much latex actually slows my little laptop to a crawl.
Best Answer
The covariance of $X$ and $Y$ is $E(XY)-E(X)E(Y)$. (The formal definition of covariance is $E((X-E(X))(Y-E(Y)))$, but that is usually, and in this case, harder to work with.)
To find $E(XY)$, find the sum $\sum_{(x,y)} xy\Pr(X=x\land Y=y)$.
There will be $9$ terms to add up, really only $7$, since $2$ of the terms are $0$,
A typical term like the one for $x=2$, $y=3$ in your table makes a contribution of $(2)(3)(0.15)$ to $E(XY)$.
Remark: The procedure of your other calculations is correct. I have not checked the arithmetic.