# Calculate probability of selecting x people of certain gender from population

Say I have a population which is evenly split into men and women. If I'm randomly selecting a sample of y, how do I calculate the probability of selecting a specific split by gender?

Example:

Total population = 150 (75 men and 75 women)

Randomly select 20 people.

What is probability of selecting 0 men and 20 women? 1 man and 19 women? 2 men and 18 women? ... etc.

Furthermore - what is the formula to generalise this if it is an unevenly split population (e.g. there are 80 men and 70 women to begin with in the example above)?

Let your total population be $T = M + W$ where $M$ is the number of men and $W$ is the number of women.
Then there are $\binom{T}{20}$ ways of choosing $20$ people. If you want to know the probability of selecting $m \le \min\{20, M\}$ men and $w \le \min\{20,W\}$ women (where $m+w = 20$), then you have $\binom{M}{m}$ and $\binom{W}{w}$ ways of selecting the men and women, respectively. Therefore, your probability is
$$\frac{\binom{M}{m}\binom{W}{w}}{\binom{T}{20}} = \frac{\binom{M}{m}\binom{W}{w}}{\binom{M+W}{m+w}}$$