TITLE: Probability of a probability to happen
QUESTION [9 upvotes]: I'm trying to solve this problem but I'm struggling to.
A university has 300 students enrolled. You sample 30 students and see that 20 are boys and 10 are girls. If the university had 150 male students and 150 females, what would be the probability of your observation? More generally,  if there are N students enrolled in the university, B of which are boys and N − B girls, what is the probability that if you sample n (≤ N), then exactly b are boys and n − b are girls?
So from the sample we know that there are (approximating) 66% boys and 33% girls. But I don't know how to estimate the probability of this observation, what am I missing?

REPLY [10 votes]: To solve this problem you can use the Hypergeometric distribution. With the variables

$N$ the population size ($300$)
$K$ number of success states in the population ($150$)
$n$ the number of draws ($30$)
$k$ the number of observed successes (boys, $20$)

Then if $X$ is the number of boys drawn in the sample then
$$
P(X = k) = \frac{{K \choose k} {N-K \choose n-k}}{N \choose n}
$$
Recall that ${n\choose k} = \frac{n!}{k!(n-k)!}$ is the binomial coefficient.
For your example of drawing $20$ boys in a sample of $30$, we have
$$
P(X = 20) = \frac{{150 \choose 20} {300-150 \choose 30-20}}{300 \choose 30} \approx 0.0245
$$
The solution with the binomial distribution provided by @Atvin is an estimation of the probability with a large population size ($N\to\infty$).