Suppose I have a population divided by nationality according to the following proportions (%):
percentages = {'Germany': 0.4, 'France': 0.25, 'Greece': 0.15, 'Poland': 0.1, 'Norway': 0.05, 'Others': 0.05}
Now I need to generate samples from this population. Is there a way in Python to generate a sample of size n
from the population?
For example, if n = 50
, I would expect to have something like:
sample = {'Germany': 22, 'France': 10, 'Greece': 8, 'Poland': 6, 'Norway': 3, 'Others': 1}