# Expected value, variance and probability from a joint distribution function

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.

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.

• Thank you once again André, that was very clear. – Display Name Apr 17 '14 at 6:08
• You are welcome. – André Nicolas Apr 17 '14 at 6:09
• Related query, if I were to have a function $G = 10 + 10X + 15Y$ using the above $X$ and $Y$, how would I go about working out the mean and standard deviation of $G$? Does the mean of G just multiply through the Mean of $X$ and $Y$ in place of X and Y I the equation? Same with taking the square root of variance and plugging it in? – Display Name Apr 17 '14 at 6:12
• The mean of $G$ is $10+10E(X)+15E(Y)$. Means are linear. Variance is more complicated. The variance of $a+bX+cY$ is $b^2\text{Var}(X)+c^2\text{Var}(Y)+2bc\text{Cov}(X,Y)$. If $X$ and $Y$ are uncorrelated (covariance is $0$, which happens when $X$ and $Y$ are independent, and in some other cases) the covariance term is $0$, which is nice. Not in your example! – André Nicolas Apr 17 '14 at 6:18