# Confusion - Law of total probability and joint PMF

As a self-learner I am struggling to understand how the law of total probability works for problems involving joint PMFs of a function of random variables (and PDFs).

For example, to calculate the PMF of two indepdenent random variables $X + Y$ when $X \sim Poisson(\lambda_1)$ and $Y \sim Poisson(\lambda_2)$ the book I am reading (Joseph Blitzstein - Introduction to probability page 166) proposes the following approach:

\begin{aligned} P(X + Y = k) & = \sum_{j = 0}^k P(X + Y = k \ | \ X = j) \ P(X = j) \\ & = \sum_{j = 0}^k P(Y = k- j \ | \ X = j) \ P(X = j) \\ & = \sum_{j = 0}^k P(Y = k- j ) \ P(X = j) \ \textit{ drop conditioning by independence of X and Y} \end{aligned}

### Question: where does the sum $\sum_{j = 0}^k$ come from ?

When approaching this problem my intuition would be to use the joint PMF: $P_{XY}(x,y) = P(X = x, Y = y)$ and combine it with Bayes rule $P(A \cap B) = P(A | B) P(B)$ to get:

\begin{aligned} P(X + Y = k) & = P(Y = k - j \cap X = j ) \\ & = P(Y = k - j \ | \ X = j ) \ P(X = j) \end{aligned}

###  - Solved - worked example

Consider the case where $k = 2$ then:

\begin{aligned} & P(X + Y = 2) = P(X + Y = 2| X = 0 )P(X = 0 ) + P(X + Y = 2 | X = 1 )P(X = 1 ) + P(X + Y = 2 | X = 2 )P(X = 2 ) \\ \\ & = P(Y = 2 | X =0)P(X = 0 ) + P(Y = 1 | X =1)P(X = 1 ) + P(Y = 0 | X =2)P(X = 2 ) \\ \\ & = P(Y = 2 )P(X = 0 ) + P(Y = 1 )P(X = 1 ) + P(Y = 0 )P(X = 2 ) \textit{ by indep.} \\ \\ & = \sum_{j=0}^2P(Y= 2 - j)P(X = j) \end{aligned}

We are aware that the disjoint sets $\{ X = j \}$ $(j = 0, \dots, k)$ form a partition of the underlying "urn". Then $$P\{ X + Y = k \} = P(\bigcup_{j=0}^{k}\{ X + Y = k\} \cap \{ X = j\}) = \sum_{j=0}^{k}P\{ X + Y = k\ \text{and}\ X = j\} = \sum_{j=0}^{k}P\{X + Y = k \mid X = j\}P\{ X = j \}.$$ So the sum over $j$ comes from the union. Intuitively, the sum comes from cutting the event $\{ X + Y = k \}$ into pieces with the sets $\{ X = j \}$ and then patching them up.