Jump to content

User:Vossman/Weighted running sums

From Wikipedia, the free encyclopedia
See weight function for the continuous case.

The weighted mean, or weighted average, of a non-empty list of data

with corresponding non-negative weights

at least one of which is positive, is the quantity calculated by

which means:

So data elements with a high weight contribute more to the weighted mean than do elements with a low weight.

If all the weights are equal, then the weighted mean is the same as the arithmetic mean. While weighted means generally behave in a similar fashion to arithmetic means, they do have a few counter-intuitive properties, as captured for instance in Simpson's paradox.

Weighted versions of other means can also be calculated. Examples of such weighted means include the weighted geometric mean and the weighted harmonic mean.

The notion of weighted mean plays a role in descriptive statistics and also occurs in a more general form in several other areas of mathematics.

In the special case, often encountered in practice, where the weights are normalized (i.e. are nonnegative and sum up to 1), the denominator of the fraction simplifies to 1.

Weighted sample variance

[edit]

Typically when you calculate a mean it is important to know the variance and standard deviation of that mean. When a weighted mean is used, the variance of the weighted sample is different from the variance of the unweighted sample. The biased weighted sample variance is defined similarly to the normal biased sample variance:


For small sample of populations, it is customary to use an unbiased estimator for the population variance. In normal unweighted samples, the N in the denominator (corresponding to the sample size) is changed to N-1. While this is simple in unweighted samples, it becomes tedious for weighted samples. Thus, the unbiased estimator of weighted population variance is given by [1]:


Which can also be written in terms of running sums for programming as:

The standard deviation is simply the square root of the variance above.