Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's a question I got for homework:

A student purchases books for $K$ class hours, where $K$ is a random variable with a uniform distribution between $1$ to $3$. The number of books the students purchases is also a random variable defined by $P(N=n|K=k) = 1/k$, $n = 1,\dots,k$.

What is the joint distribution, what is the marginal probability function of N?

So, first I wrote down $P(K=k): 1/3$, $k=1,2,3$

Now, $P(N=n|K=k) = P(N=n \text{ and } K=k)/P(K=k) = 1/k$, and from that I got $P(N=n\text{ and }K=k) = (1/k)P(K=k)$. When I write down the table of joint distribution the disjoints events didn't sum up to $1$. For example:

\begin{align*} P(N=1|K=1) &= 1 \\ P(N=1|K=2) &= 1/6 \\ P(N=1|K=3) &= 1/9 \\ \end{align*}

You'll notice that I get P(N=n) = 11/18 for n=1,2,3 And that's what I mean when I say it didn't sum up to 1.

There's obviously something I don't understand, a hint would be great. Where is my mistake? Thanks!

share|cite|improve this question
Those are conditional probabilities you are adding, not joint dist. values. You want to find, for example, $P[N=1, K=1]$, $P[N=1, K=2]$, $P[N=1, K=3]$. The sum of these is the marginal distribution of $N$ evaluated at $1$ (and need not be 1). The sum of all $P[N=i, K=j]$ would be 1. – David Mitra Dec 12 '11 at 10:46
I know what's your saying is right but the sum I get is 11/6. Is there any way to draw a table here? – yotamoo Dec 12 '11 at 10:52
So you're given $P[K=k]=\frac{1}{3}$ for $1 \leq k \leq 3$ and $P[N=n|K=k]=$\frac{1}{k}$ for $1 \leq n \leq k$ (and $0$ for $n>k$). Therefore $P[N=n,K=k]=P[N=n|K=k] \cdot P[K=k] = \frac{1}{3k}$ for $1 \leq n \leq k \leq 3$ but $0$ for $n>k$. Finally, $P[N=n]=\sum_{k=n}^{3}P[N=n|K=k]=\sum_{k=n}^{3}\frac{1}{3k}$. – bgins Dec 12 '11 at 11:10
up vote 1 down vote accepted

It's the conditional distributions that don't add to one. Try drawing the joint distribution $P[N=n,K=k]$ in a table for $1 \leq k,n \leq 3$: the nonzero values will form a triangle, where each row and column have sums that make sense. And compare this with the conditional distributions (which are shown first below): $$ \begin{array}{ccc} P[N=n|K=k] & n=1 & n=2 & n=3 \\ k=1 & 1 & 0 & 0 \\ k=2 & \frac{1}{2} & \frac{1}{2} & 0 \\ k=3 & \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \end{array} $$ $$ \begin{array}{ccc} P[N=n,K=k] & n=1 & n=2 & n=3 \\ k=1 & \frac{1}{3} & 0 & 0 \\ k=2 & \frac{1}{6} & \frac{1}{6} & 0 \\ k=3 & \frac{1}{9} & \frac{1}{9} & \frac{1}{9} \end{array} $$ So you're given $P[K=k]=\frac{1}{3}$ for $1 \leq k \leq 3$ and $$ P[N=n|K=k]= \left\{ \begin{align} \frac{1}{k} &\quad \text{for }1 \leq n \leq k; \\ 0 &\quad\text{for }n>k. \end{align} \right. $$ This is the conditional distribution, shown in the first table above. From this, we can calculate the joint distribution as in the second table: $P[N=n,K=k]=P[N=n|K=k] \cdot P[K=k] = \frac{1}{3k}$ for $1 \leq n \leq k \leq 3$ (and $0$ for $n>k$). Finally, $P[N=n]=\sum_{k=n}^{3}P[N=n|K=k]=\sum_{k=n}^{3}\frac{1}{3k}$.

As pointed out by others, the mistake was in writing down the conditional probabilities.

share|cite|improve this answer
Okay but if there's no mistake then P(N=2,K=1)=(1/k)P(K=k) = 1/3, but you have 1/6. How did you get it? Sorry I have the impression that I did have a mistake somewhere, otherwise I don't see how you got your table. Anyway- thanks – yotamoo Dec 12 '11 at 11:09

One mistake is writing:

$ \begin{align*} P(N=1|K=1) &= 1 \\\\ P(N=1|K=2) &= 1/6 \\\\ P(N=1|K=3) &= 1/9 \\\\ \end{align*}$

The expressions on the left hand side are conditional probabilities. Using the formula in the problem statement, they should be

$ \begin{align*} P(N=1|K=1) &= 1 \\\\ P(N=1|K=2) &= 1/2 \\\\ P(N=1|K=3) &= 1/3 \\\\ \end{align*}$

Joint distribution values for $N=1$ can be obtained from the above and your formula: $$P(N=n\text{ and }K=k) = (1/k)P(K=k), {\text { for }} n\le k$$


$ \begin{align*} P(N=1\text{ and }K=1) &= 1\cdot(1/3)=1/3 \\\\ P(N=1\text{ and }K=2) &= 1/2 \cdot(1/3)=1/6\\\\ P(N=1\text{ and }K=3) &= 1/3\cdot(1/3)=1/9 \\\\ \end{align*}$

Adding these gives $P[N=1]={1\over 3}+{1\over 6} +{1\over 9}={11\over 18}$.

To find the rest of the joint distribution values, you need to observe (assume?) that $P[N=n|K=k]=0$ if $n>k$; so $P[N=n,K=k]=0$ for $n>k$.

See bgins answer for the full joint distribution.

share|cite|improve this answer
@yotamoo The essential observation you need to make is that $P[N=n|K=k]=0$ if $n>k$. – David Mitra Dec 12 '11 at 11:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.