# Using conditional PMF to find marginal PMF

The problem is as follows:

Alvin shops for probability books for K hours, where K is a random variable that is equally likely to be 1, 2, 3, or 4. The number of books N that he buys is random and depends on how long he shops according to the conditional PMF $p_{N|K}(n,k) = \frac{1}{k}$ for n = 1,...,k.

I had found the joint PMF to be $\frac{1}{4k}$ for k = 1,2,3,4 and n = 1,...,k.

However the next question asks to find the marginal PMF of N. Now I would assume that since the joint PMF is independent of N, then if I were to draw a table, each cell in the ith column of k would be the same.

Yet when I check my answer, the marginal PMF is given by $\sum_{k=n}^4 \frac{1}{4k}$, and this does not correspond to my thinking, as it suggests the entry in n=4, k=1 is 0, or is at least not included in the sum.

Can anyone help me understand why this is?

It is perhaps easier to see with the table drawn. The conditional probability table of $P(N|K)$ is given by:

$\:\:\qquad$$k=1$$k=2$$k=3$$k=4$
$n=1$$\hspace{-1pt}\quad1\quad$$\!\quad\frac{1}{2}\!\quad$$\!\quad\frac{1}{3}\!\quad$$\!\quad\frac{1}{4}\!\quad$
$n=2$$\hspace{-1pt}\quad0\quad$$\!\quad\frac{1}{2}\!\quad$$\!\quad\frac{1}{3}\!\quad$$\!\quad\frac{1}{4}\!\quad$
$n=3$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\!\quad\frac{1}{3}\!\quad$$\!\quad\frac{1}{4}\!\quad$
$n=4$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\!\quad\frac{1}{4}\!\quad$
and you are somewhat correct in saying that the values of probabilities across the columns are the same, but that is only true for $n\le k$ so beware of the 0 probabilities. I think this is where your confusion arose.

As $K$ has equal probability of taking the values 1, 2, 3 or 4, i.e. $P(K) = \frac{1}{4}$, the table of joint distribution P(N,K) is given by multiplying the table of the conditional probabilities by $\frac{1}{4}$ to give:

$\:\:\qquad$$k=1$$k=2$$k=3$$k=4$
$n=1$$\!\quad\frac{1}{4}\!\quad$$\!\quad\frac{1}{8}\!\quad$$\!\!\quad\frac{1}{12}\!\!\quad$$\!\!\quad\frac{1}{16}\!\!\quad$
$n=2$$\hspace{-1pt}\quad0\quad$$\!\quad\frac{1}{8}\!\quad$$\!\!\quad\frac{1}{12}\!\!\quad$$\!\!\quad\frac{1}{16}\!\!\quad$
$n=3$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\!\!\quad\frac{1}{12}\!\!\quad$$\!\!\quad\frac{1}{16}\!\!\quad$
$n=4$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\hspace{-1pt}\quad0\quad$$\!\!\quad\frac{1}{16}\!\!\quad$

The marginal probability is simply the sum of the conditional probabilities across the rows, and it is therefore evident that $P(N)=\sum_{k=n}^4 \frac{1}{4k}$.