Joint probability mass function illustrated with balls and coin flips, showing table of probabilities and expected value calculation

What is a Joint Probability Mass Function?

Imagine we have two discrete random variables, $X$ and $Y$. Their joint probability mass function tells us probabilities of events like $X$ being equal to $1$ and $Y$ being equal to $0$, both at the same time.

More generally, given two numbers $x$ and $y$, the joint PMF gives us the probability $\mathbb{P}(X=x,Y=y)$.

We can then find expected values of functions of both random variables, like $\mathbb{E}(XY)$, as follows:

$$\mathbb{E}(XY) = \sum_{\forall x,y} \ xy \ \mathbb{P}(X=x,Y=y)$$

Where $\forall$ means “for all”, and we sum over all values $x$ and $y$ that $X$ and $Y$ might take, respectively.

If we want to find the expected value of some other function, $g(X,Y)$, we just replace $xy$ with $g(x,y)$ in the sum:

$$\mathbb{E}(g(X,Y)) = \sum_{\forall x,y} \ g(x,y) \ \mathbb{P}(X=x,Y=y)$$

Background: