Marginal Distributions

Interact

What does the joint distribution of $X$ and $Y$ tell us about the distribution of $X$ alone?

Everything, of course. Let’s see how.

Here is the joint distribution table of two random variables $X$ and $Y$.

joint_table
X=0 X=1 X=2
Y=5 0.00000 0.0000 0.03125
Y=4 0.00000 0.0625 0.09375
Y=3 0.03125 0.1875 0.09375
Y=2 0.09375 0.1875 0.03125
Y=1 0.09375 0.0625 0.00000
Y=0 0.03125 0.0000 0.00000

To find the distribution of $X$ we need the possible values of $X$ and all their probabilities.

At a glance, you can see that the possible values of $X$ are 0, 1, and 2.

Let’s look at the event ${ X = 0 }$.

def indicator_X_equals_0(i, j):
    return i == 0

joint_table.event(indicator_X_equals_0, 'X', 'Y')
P(Event) = 0.25

X=0 X=1 X=2
Y=5 0.00000
Y=4 0.00000
Y=3 0.03125
Y=2 0.09375
Y=1 0.09375
Y=0 0.03125

These are the cells in the column labeled X=0. The sum of the probabilities in those cells is $P(X = 0) = 0.25$.

Partitioning ${X = x }$ According to $Y$

In every cell of the column labeled X=0, the value of $X$ is 0 and the value of $Y$ is some possible value of $Y$. So the column X=0 partitions the event ${X = 0}$ according to the value of $Y$, and displays the probability of each piece of the partition.

In other words, for every $x$ we have and this is a disjoint union. So by the addition rule,

That is, $P(X = x)$ is the sum of the probabilities in the column X=x. Because $P(X = x)$ is the generic term in the distribution of $X$, we have learned that we can derive the distribution of $X$ from the joint distribution of $X$ and $Y$.

Marginal Distribution of $X$

To find the numerical values of the distribution of $X$, we will use a method called marginal that operates on a joint distribution object and takes the variable name as its argument. The reason for using the word “marginal” will become clear as soon as we see the output.

joint_table.marginal('X')
X=0 X=1 X=2
Y=5 0.00000 0.0000 0.03125
Y=4 0.00000 0.0625 0.09375
Y=3 0.03125 0.1875 0.09375
Y=2 0.09375 0.1875 0.03125
Y=1 0.09375 0.0625 0.00000
Y=0 0.03125 0.0000 0.00000
Sum: Marginal of X 0.25000 0.5000 0.25000

Now at the bottom of the table you have all the column sums, which constitute the probabilities in the distribution of $X$.

Because the sums appear in the margin of the table, the distribution is called marginal. It’s a bit silly. But “marginal” is a commonly used term for the probability distribution of $X$ when the distribution has been derived from a joint distribution.

You should recognize that $X$ has the same distribution as the number of heads in two tosses of a coin.

Both Marginals

What you can do for $X$, you can do as well for $Y$ by looking along the rows.

joint_table.marginal('Y')
X=0 X=1 X=2 Sum: Marginal of Y
Y=5 0.00000 0.0000 0.03125 0.03125
Y=4 0.00000 0.0625 0.09375 0.15625
Y=3 0.03125 0.1875 0.09375 0.31250
Y=2 0.09375 0.1875 0.03125 0.31250
Y=1 0.09375 0.0625 0.00000 0.15625
Y=0 0.03125 0.0000 0.00000 0.03125

You can also get both marginals at once:

joint_table.both_marginals()
X=0 X=1 X=2 Sum: Marginal of Y
Y=5 0.00000 0.0000 0.03125 0.03125
Y=4 0.00000 0.0625 0.09375 0.15625
Y=3 0.03125 0.1875 0.09375 0.31250
Y=2 0.09375 0.1875 0.03125 0.31250
Y=1 0.09375 0.0625 0.00000 0.15625
Y=0 0.03125 0.0000 0.00000 0.03125
Sum: Marginal of X 0.25000 0.5000 0.25000 1.00000

The bottom right corner cell is the sum of all the probabilities in the table, and also the sum of all the probabilities in each of the margins. Reassuringly, it’s 1.