I'm reading hands on machine learning with SciKit-Learn and TensorFlow by Aurélien Géron and came across this passage on page 51:

For example, the US population is composed of 51.3% female and 48.7% male, so a well-conducted survey in the US would try to maintain this ratio in the sample: 513 female and 487 male. This is called stratified sampling: the population is divided into homogeneous subgroups called strata, and the right number of instances is sampled from each stratum to guarantee that the test set is representative of the overall population. If they used purely random sampling, there would be about 12% chance of sampling a skewed test set with either less than 49% female or more than 54% female.

It is not at all clear to me, how the 12% figure quoted above, is calculated. Could someone shed some light on this?


Make a few approximations: 1) US population is large enough that we are sampling with replacement, and 2) that n=1000 binomial is large enough to be Gaussian with mean=np and variance=np(1-p).

Here, $n = 1000$, $p = 0.513$. So, 1 standard deviation $= 15.8$.

49% = -1.45z and 54% = 1.7z

$P$(sampling outside of -1.45 to 1.7$)$ = $1-P$(sampling inside) =

$1 - (\Phi(1.7) - \Phi(-1.45)) =\\ 1 - (0.9554 - 0.0808) =\\ 0.1254%$

Or you can do away with approximation 2) and do a bunch of summations with the binomial distribution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.