# Expected values (for covariance) from discrete distribution table

Well given two Bernoulli distributed random variables $X \in [0,1]$ and $Y \in [0,1]$

And the joint probability distribution table (Where $p_x$ and $p_y$ are the marginal probability mass functions for $X$ and $Y$

$$\begin{array}{l|cc|c} a &Y=0 & Y = 1 & p_x \\ \hline X = 0 & 0.2 & 0.2 & 0.4\\ X = 1 & 0.2 & 0.4 & 0.6 \\ \hline p_y & 0.4 & 0.6 \end{array}$$

Now $E[X]$ and $E[Y]$ follow easily, from the marginal probability:

$$E[X] = \sum \limits_i a_i p_x(a_i) = 0.4 \cdot 0 + 0.6 \cdot 1 = 0.6$$ $$E[Y] = 0.6$$

However for covariance I also need the combined expected value: $E[XY]$. This might be a complete simple thing I missed - since the textbook I am using doensn't even explain it, but how would I get this?

In the general case, should I just "make a table with $X\cdot Y$ and the summed probabilities for these values?"
(Which in the 2 variable case above would simple mean that $E[XY] = P(X = 1 \cap Y = 1) = 0.4$)

Yes, your intuition is correct. Although most summands are $0$, and indeed the expectation is equal to $0.4$ as you observed, here is the complete formula so that you can apply it in general: \begin{align}E[XY]&=\sum_{x,y}xyP(X=x,Y=y)=\sum_{x=0}^{1}\sum_{y=0}^1xyP(X=x,Y=y)\\[0.3cm]&=\phantom{+}0\cdot 0\cdot P(X=0,Y=0)+0\cdot 1 \cdot P(X=0,Y=1)\\[0.3cm]&\hspace{8.5pt}+1\cdot0 \cdot P(X=1,Y=0)+1\cdot 1\cdot P(X=1,Y=1)\\[0.3cm]&=\phantom{+}1\cdot0.4+0=0.4\end{align}