# Mass of single random variable from joint mass

I'm taking a course on probability and confused about single variable mass and joint mass. Here is a quote of the video, I'm learning from:

Using the joint mass to calculate the mass of a single random variable. For instance, consider two random variables $$X$$ and $$Y$$. If we sum the values of the joint mass $$p_{X,Y}(x,y)$$ over all possible $$y$$ values,

$$\sum_y p_{X,Y}(x,y) = \sum_y P(X=x, Y=y) \\= P(X=x, Y=\text{anything}) = P(X=x) = p_X(x)$$

It's stated that the mass of a single variable, $$X$$, is simply the sum of the joint mass over all possible values of $$Y$$.

I'm not really following the logic of this. Specifically, where does the $$Y=\text{anything}$$ come from? And why does the $$Y$$ term disappear to leave just the mass of $$X$$?

I'm a beginner to the topic, so any simple explanation would be appreciated.

You have a bag of red and blue triangles and squares. You draw the figures randomly with replacement from the bag. You want to calculate the probability of drawing square of any color from the bag. Draw a $$2\times2$$ table with counts of all objects in the bag:

$$\begin{array}{cc} & \triangle & \square \\ \color{blue}{\text{blue}} & 11 & 25 \\ \color{red}{\text{red}} & 9 & 55 \\ \end{array}$$

Now

$$P(\square) = P(\color{blue}{\square}) + P(\color{red}{\square}) = \frac{25}{100} + \frac{55}{100}$$

So the formula combines the rows, saying it differently, it ignores the colors:

$$\begin{array}{cc} & \triangle & \square \\ & 20 & 80 \\ \end{array}$$

What the formula does, it just uses abstract symbols, so $$P(\color{blue}{\square}) = P(X=\square,\,Y=\color{blue}{\text{blue}})$$. The $$Y=\text{anything}$$ is just a clumsy notation to say $$Y\in\{\color{blue}{\text{blue}}, \color{red}{\text{red}}\}$$ in above case, as $$Y$$ can be any color, where only two are possible.

This is the law of total probability.