Survey respondents and logged events often carry weights: one respondent may represent 500 people, another 2,000. Unweighted averages then give the wrong answer.
Implement:
weighted_mean(x, w): weighted_var(x, w): the population-style weighted variance effective_sample_size(w): Kish's formula . Uneven weights mean less information than the raw count suggests.Raise ValueError for negative weights, mismatched lengths, or weights that sum to 0.