In the world of surveys, it is very common that our acquired responses need to be weighted in order to achieve a sample that is representative of some target population. This process of weighting simply consists of assigning a weight (a.k.a. factor) to each respondent and calculating all survey results as a weighted sum of respondents.
For example, we might have surveyed 100 male respondents and 150 female respondents but we're targeting a male/female ratio of 48%/52%. In this simple case, we could achieve the target ratio by weighting the male responses by a factor of
0.48 / (100 / (100 + 150)) = 1.2 and weighting the female responses by
0.52 / (150 / (100 + 150) = 0.867. The technical term for this method of computing weights is Post-Stratification.
However, in a more complex scenario, where we have many different measurable demographic targets, how can we determine weights for all the survey respondents?