Probability of a probability to happen 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? 
 A: If you can pick the same boy (or girl) twice, then this is the correct answer:
This can be solved using the binomial distribution:
You sample $30$ students, and the probability of choosing a boy is $\frac12$. Therefore, you have $Binom(30,\frac12$):
$$\mathbb{P}(X=20)=\binom{30}{20} \frac12^{20} \frac12^{10}=\mathbb{P}(X=10)=\binom{30}{10} \frac12^{10} \frac12^{20}$$
You can see that the result is the same, if you ask for the probability of sampling $10$ girls (right side of the equation), since if you know the numbers from one gender, you will automatically know the numbers from the other gender.
If you can't pick the same boy (or girl) twice, this is the correct answer (with credit to lulu):
$$\frac{\binom{150}{20} \cdot \binom{150}{10}}{\binom{300}{30}}=\frac{\binom{150}{10} \cdot \binom{150}{20}}{\binom{300}{30}}$$
since $\binom{300}{30}$ is the number of all possible samples, and from the $150$ boys, you choose exactly $20$ (or equivalently, from the $150$ girls, you choose exactly $10$).
This is called the hypergeometric distribution.
I will leave the general case for you to work out.
A: 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$).
