Probability that two independent samples, each one without repetition, share K elements Consider the following experiment:


*

*Population of size $N$.

*Two independent samples, each one without replacements.

*Samples have different number of trials, let's say $n_1$ and $n_2$.


What's the probability that these samples share exactly $K$ elements? Please note that I say "share" in any order, not "match".
 A: Clearly if $K \gt n_1$ or $K \gt n_2$, the outcome that the two samples share exactly $K$ elements is impossible.  So let's assume $K \le n_1,n_2$.
Further it is required, if the outcome is to be possible, that (accounting for the samples' overlap) $N \ge n_1 + n_2 - K$.
Computing a probability here probably assumes all subsets of a given size are equally likely as "samples" of that size.  So let's begin by counting how many distinct outcomes there are, if both an $n_1$-subset and an $n_2$-subset are chosen.
Since these are independently sampled, there are $\binom{N}{n_1}$ possibilities for the first sample and $\binom{N}{n_2}$ possibilities for the second sample.  Thus the entire outcome space has size:
$$ \binom{N}{n_1} \cdot \binom{N}{n_2} $$
Once the narrowed class of outcomes where the two samples have exactly $K$ elements in common is counted, the probability will then be the ratio of this latter count to the size of the entire outcome space counted above.
One way to think about this narrowed counting task is to first pick out the $K$ element subset that will be shared by the two samples.  There are $\binom{N}{K}$ ways to pick that shared subset.
Then consider how many ways to pick the remaining $n_1 - K$ elements of the first sample from the $N - K$ elements that remain.  This can be done in $\binom{N-K}{n_1 - K}$ ways.
Finally we must choose the $n_2 - K$ elements that make up the remainder of the second sample, but (since there can be no further overlap) these must be taken from the $N - n_1$ elements outside the first sample.  Here we need the condition that $N - n_1 \ge n_2 - K$ to make such a choice possible.  The number of ways to do this is $\binom{N - n_1}{n_2 - K}$.
Putting everything together in one expression, the probability is:
$$ \frac{\binom{N}{K} \binom{N-K}{n_1 - K} \binom{N - n_1}{n_2 - K}}{\binom{N}{n_1} \cdot \binom{N}{n_2}} $$
Simplifying this expression (through use of factorials) is left as an exercise for the Readers.
