# Probability of getting $k$ answers correct in an exam with 4 and 2 questions on $N$ possible subjects?

The problem

I'm stuck on a "recreational" problem. This is not homework.

A student has to take an exam on $N$ possible subjects. The exam is split into two sections, $A$ and $B$. Section $A$ has 4 questions, each on a different subject. Section $B$ has 2 questions. The student can answer maximally 3 out of 4 question in section $A$ and maximally 1 out of 2 questions in section $B$. The maximum number of answers the student can answer correctly in the exam is thus 4.

The 4 and 2 subjects in sections $A$ and $B$ are drawn without replacement from the $N$ possible subjects. No subject appears in both sections simultaneously.

Before the exam, the student studies $K$ out of the $N$ subjects with $K\leq N$. If the student studied a specific subject, we assume that he can answer the question on that subject correctly.

What is the probability that the student can answer $k$ answers in the exam when he has prepared $K$ subjects ($k\leq 4$)?

What I have tried

Both sections can be modelled by a hypergeometric distribution, I think. So for section $A$ with $n=4$ we have: $$P(X = k) = \frac{\binom{K}{k}\binom{N-K}{4-k}}{\binom{N}{4}}$$

But I'm unsure how to proceed and how to model both sections together.

Any help is appreciated. Thank you.

• "The 4 and 2 subjects in sections A and B are drawn without replacement from the N possible subjects. No subject appears in both sections simultaneously." -- hang on -- since the first sentence there precludes a subject being repeated within a section and the second sentence precludes a repeat across sections, isn't that just the same as saying "the six subjects across the six questions on the exam are chosen without replacement"?? Given that second sentence, why distinguish between the sections at all? Commented Jan 13, 2015 at 6:08
• @Glen_b That's exactly why I'm confused. At first, I thought that the distinction is irrelevant and that we could model it with a hypergeometric distribution with parameters H(N, K, 6). But I think we have to split it into a hypergeometric distribution H(N, K, 4) for section A and H(N-4, K-Xa, 2), where Xa is the number of subjects in section A that the student prepared for Commented Jan 13, 2015 at 7:43
• Ah, I forgot about the maximum number of questions you can answer in each section. Commented Jan 13, 2015 at 9:33
• Probability questions can be very tricky. I do not see the 3 out of 4 and 1 out of 2 in your formula. Are they there? Commented Jan 14, 2015 at 18:36
• @JoelW. No, not really. That's my problem, I don't know how to proceed :) Commented Jan 15, 2015 at 8:15

Consider each section of the exam as containing the result of several draws (without replacement) from an urn. The urn contains the K subjects the student studied, and the N - K subjects he/she skipped. Let J = N - K, for convenience.

Part A contains between 0 and 4 subjects that the student studied, while part B contains between 0 and 2 such subjects.

Now, for each of these 15 possible combinations, consider the value of k that that combination gives rise to:

k = 0: 0 correct on part A, 0 correct on part B
k = 1: 0 correct on part A, 1 or 2 correct on part B, OR
1 correct on part A, 0 correct on part B
k = 2: 1 correct on part A, 1 or 2 correct on part B, OR
2 correct on part A, 0 correct on part B
k = 3: 2 correct on part A, 1 or 2 correct on part B, OR
3 correct on part A, 0 correct on part B, OR
4 correct on part A, 0 correct on part B
k = 4: 3 correct on part A, 1 or 2 correct on part B, OR
4 correct on part A, 1 or 2 correct on part B


At this point, it's just a matter of summing up the probabilities of the configurations, for each value of k. Let f(k, K, J, n) be the pmf of the hypergeometric distribution, with k white balls drawn, K white balls and J black balls in the urn, and n balls drawn overall. Then the probabilities are:

k = 0: f(0, K, J, 4) * f(0, K, J - 4, 2)
k = 1: f(0, K, J, 4) * (f(1, K, J - 4, 2) + f(2, K, J - 4, 2)) +
f(1, K, J, 4) * f(0, K - 1, J - 3, 2)
k = 2: f(1, K, J, 4) * (f(1, K - 1, J - 3, 2) + f(2, K - 1, J - 3, 2)) +
f(2, K, J, 4) * f(0, K - 2, J - 2, 2)
k = 3: f(2, K, J, 4) * (f(1, K - 2, J - 2, 2) + f(2, K - 2, J - 2, 2)) +
f(3, K, J, 4) * f(0, K - 3, J - 1, 2) +
f(4, K, J, 4) * f(0, K - 4, J, 2)
k = 4: f(3, K, J, 4) * (f(1, K - 3, J - 1, 2) + f(2, K - 3, J - 1, 2)) +
f(4, K, J, 4) * (f(1, K - 4, J, 2) + f(2, K - 4, J, 2))


I'm assuming the probability is just 0 wherever the distribution isn't supported (e.g., where k > K).

As Joel W. says in the comments, probability is tricky, and it's always worth checking your work with a simulation. Here's my R code to do just that (with N set to 25 and K to 17; you could of course set these to whatever you wanted):

N <- 25
K <- 17

subjects <- seq(from = 1, to = N)
studied <- sample(subjects, K)

})



Running the above, I got these observed proportions:

k = 0: 0.00016
k = 1: 0.00910
k = 2: 0.09298
k = 3: 0.34898
k = 4: 0.54879


Meanwhile, using R to evaulate the probabilities described above (with 25 and 17 substituted for N and K), I got:

k = 0: 0.00016
k = 1: 0.00896
k = 2: 0.09318
k = 3: 0.34762
k = 4: 0.55009


Good enough agreement, I think, to lend credence to my solution. (Happily, the probabilities sum to 1, ignoring a bit of rounding error.)

I realize that a single overall formula would have been more satisfying than the tabulation-based approach I took above. Unfortunately, I wasn't able to come up with a clean, readable formula that encapsulated all the various sums. I think the distinction between answerable and answered questions really complicates the problem, but it could very well be that someone more skilled in probability/combinatorics could find a way to express the various sums as a single crisp formula.