The weighted arithmetic mean is similar to an ordinary arithmetic mean (the most common type of average), except that instead of each of the data points contributing equally to the final average, some data points contribute more than others. 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.
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 counterintuitive properties, as captured for instance in Simpson's paradox.
Given two school with 20 students, one with 30 test grades in each class as follows:
Morning class =
Afternoon class =
The mean for the morning class is 80 and the mean of the afternoon class is 90. The unweighted mean of the two means is 85. However, this does not account for the difference in number of students in each class (20 versus 30); hence the value of 85 does not reflect the average student grade (independent of class). The average student grade can be obtained by averaging all the grades, without regard to classes (add all the grades up and divide by the total number of students):
Or, this can be accomplished by weighting the class means by the number of students in each class. The larger class is given more "weight":
\bar{x}=
(20 x 80)+(30 x 90) | |
20+30 |
=86.
Thus, the weighted mean makes it possible to find the mean average student grade without knowing each student's score. Only the class means and the number of students in each class are needed.
Since only the relative weights are relevant, any weighted mean can be expressed using coefficients that sum to one. Such a linear combination is called a convex combination.
Using the previous example, we would get the following weights:
20 | |
20+30 |
=0.4
30 | |
20+30 |
=0.6
Then, apply the weights like this:
\bar{x}=(0.4 x 80)+(0.6 x 90)=86.
Formally, the weighted mean of a non-empty finite tuple of data
\left(x1,x2,...,xn\right)
\left(w1,w2,...,wn\right)
\bar{x}=
| |||||||||
|
,
which expands to:
\bar{x}=
w1x1+w2x2+ … +wnxn | |
w1+w2+ … +wn |
.
Therefore, data elements with a high weight contribute more to the weighted mean than do elements with a low weight. The weights may not be negative in order for the equation to work. Some may be zero, but not all of them (since division by zero is not allowed).
The formulas are simplified when the weights are normalized such that they sum up to 1, i.e., .For such normalized weights, the weighted mean is equivalently:
\bar{x}=
n | |
\sum\limits | |
i=1 |
{wi'xi}
wi'=
wi | ||||||
|
The ordinary mean is a special case of the weighted mean where all data have equal weights.
If the data elements are independent and identically distributed random variables with variance
\sigma2
\sigma\bar{x
See main article: Inverse-variance weighting.
See also: Weighted least squares.
For the weighted mean of a list of data for which each element
xi
2 | |
\sigma | |
i |
wi=
1 | ||||||
|
.
The weighted mean in this case is:
\bar{x}=
| |||||||||
|
n | |
\right)}{\sum | |
i=1 |
2 | |
\dfrac{1}{\sigma | |
i |
\sigma\bar{x
Note this reduces to
\sigma\bar{x
\sigmai=\sigma0
2 | |
\sigma | |
\barx |
=
n | |
\sum | |
i=1 |
2 | |
{w | |
i' |
2 | |
\sigma | |
i} |
=
| |||||||||||||||||||||
}{\left(\sum |
n | |
i=1 |
-2 | |
\sigma | |
i |
\right)2}.
The equations above can be combined to obtain:
\bar{x}=\sigma\bar{x
The significance of this choice is that this weighted mean is the maximum likelihood estimator of the mean of the probability distributions under the assumption that they are independent and normally distributed with the same mean.
The weighted sample mean,
\bar{x}
If the observations have expected valuesthen the weighted sample mean has expectationIn particular, if the means are equal,
\mui=\mu
When treating the weights as constants, and having a sample of n observations from uncorrelated random variables, all with the same variance and expectation (as is the case for i.i.d random variables), then the variance of the weighted mean can be estimated as the multiplication of the unweighted variance by Kish's design effect (see proof):
\operatorname{Var}(\baryw)=\hat
2 | |
\sigma | |
y |
\overline{w2 | |
With
\hat
2 | |
\sigma | |
y |
=
| ||||||||||
n-1 |
\bar{w}=
| ||||||||||
n |
\overline{w2}=
| ||||||||||||||||
n |
However, this estimation is rather limited due to the strong assumption about the y observations. This has led to the development of alternative, more general, estimators.
From a model based perspective, we are interested in estimating the variance of the weighted mean when the different
yi
In Survey methodology, the population mean, of some quantity of interest y, is calculated by taking an estimation of the total of y over all elements in the population (Y or sometimes T) and dividing it by the population size – either known (
N
\hatN
Ii
P(Ii=1\midSomesampleofsizen)=\pii
P(Ii=1|onesampledraw)=pi ≈
\pii | |
n |
pi
Since each element (
yi
Ii
y'i=yiIi
E[y'i]=yiE[Ii]=yi\pii
V[y'i]=
2 | |
y | |
i |
V[Ii]=
2 | |
y | |
i |
\pii(1-\pii)
When each element of the sample is inflated by the inverse of its selection probability, it is termed the
\pi
\checkyi=
yi | |
\pii |
p
yi | |
pi |
=n\checkyi
\checky'i=Ii\checkyi=
Iiyi | |
\pii |
In this design based perspective, the weights, used in the numerator of the weighted mean, are obtained from taking the inverse of the selection probability (i.e.: the inflation factor). I.e.:
wi=
1 | |
\pii |
≈
1 | |
n x pi |
If the population size N is known we can estimate the population mean using
\hat{\barY}known=
\hatYpwr | |
N |
≈
| ||||||||||
N |
If the sampling design is one that results in a fixed sample size n (such as in pps sampling), then the variance of this estimator is:
\operatorname{Var}\left(\hat{\barY}knownN\right)=
1 | |
N2 |
n | |
n-1 |
n | |
\sum | |
i=1 |
\left(wiyi-\overline{wy}\right)2
An alternative term, for when the sampling has a random sample size (as in Poisson sampling), is presented in Sarndal et al. (1992) as:
With
\check{y}i=
yi | |
\pii |
C(Ii,Ij)=\piij-\pii\pij=\Deltaij
\piij
\check{\Delta}ij=1-
\pii\pij | |
\piij |
\check{\Delta}ii=1-
\pii\pii | |
\pii |
=1-\pii
If the selection probability are uncorrelated (i.e.:
\foralli ≠ j:C(Ii,Ij)=0
\operatorname{Var}(\hat\barYpwr(knownN))=
1 | |
N2 |
n | |
\sum | |
i=1 |
\left(wiyi\right)2
The previous section dealt with estimating the population mean as a ratio of an estimated population total (
\hatY
N
N
\hatN
N
wi=
1 | |
\pii |
\hatN=
n | |
\sum | |
i=1 |
wiIi=
n | |
\sum | |
i=1 |
Ii | |
\pii |
=
n | |
\sum | |
i=1 |
\check1'i
yi
R=\barY=
| |||||||||||||
|
=
| ||||||||||
|
=
| ||||||||||
|
\hatR=\hat{\barY}=
| |||||||||||||
|
=
| ||||||||||
|
=
| ||||||||||
|
=
| ||||||||||
|
=\baryw
\baryw=
| ||||||||||
|
\baryw=
| ||||||||||
|
This is called a Ratio estimator and it is approximately unbiased for R.
In this case, the variability of the ratio depends on the variability of the random variables both in the numerator and the denominator - as well as their correlation. Since there is no closed analytical form to compute this variance, various methods are used for approximate estimation. Primarily Taylor series first-order linearization, asymptotics, and bootstrap/jackknife. The Taylor linearization method could lead to under-estimation of the variance for small sample sizes in general, but that depends on the complexity of the statistic. For the weighted mean, the approximate variance is supposed to be relatively accurate even for medium sample sizes. For when the sampling has a random sample size (as in Poisson sampling), it is as follows:
\widehat{V(\baryw)} =
1 | |||||||||||||||
|
n | |
\sum | |
i=1 |
2 | |
w | |
i |
(yi-\bar
2 | |
y | |
w) |
If
\pii ≈ pin
wi=
1 | |
\pii |
wi=
1 | |
pi |
wi
We have (at least) two versions of variance for the weighted mean: one with known and one with unknown population size estimation. There is no uniformly better approach, but the literature presents several arguments to prefer using the population estimation version (even when the population size is known). For example: if all y values are constant, the estimator with unknown population size will give the correct result, while the one with known population size will have some variability. Also, when the sample size itself is random (e.g.: in Poisson sampling), the version with unknown population mean is considered more stable. Lastly, if the proportion of sampling is negatively correlated with the values (i.e.: smaller chance to sample an observation that is large), then the un-known population size version slightly compensates for that.
For the trivial case in which all the weights are equal to 1, the above formula is just like the regular formula for the variance of the mean (but notice that it uses the maximum likelihood estimator for the variance instead of the unbiased variance. I.e.: dividing it by n instead of (n-1)).
It has been shown, by Gatz et al. (1995), that in comparison to bootstrapping methods, the following (variance estimation of ratio-mean using Taylor series linearization) is a reasonable estimation for the square of the standard error of the mean (when used in the context of measuring chemical constituents):[2]
\widehat{\sigma\bar{x
2} | |
w} |
=
n | |
(n-1)(n\bar{w |
)2}\left[\sum(wixi-\bar{w}
2 | |
\bar{x} | |
w) |
- 2\bar{x}w\sum(wi-\bar{w})(wixi-\bar{w}\bar{x}w) +
2 | |
\bar{x} | |
w |
\sum(wi-\bar{w})2\right]
where
\bar{w}=
\sumwi | |
n |
\widehat{\sigma\bar{x
Gatz et al. mention that the above formulation was published by Endlich et al. (1988) when treating the weighted mean as a combination of a weighted total estimator divided by an estimator of the population size,[3] based on the formulation published by Cochran (1977), as an approximation to the ratio mean. However, Endlich et al. didn't seem to publish this derivation in their paper (even though they mention they used it), and Cochran's book includes a slightly different formulation.[4] Still, it's almost identical to the formulations described in previous sections.
Because there is no closed analytical form for the variance of the weighted mean, it was proposed in the literature to rely on replication methods such as the Jackknife and Bootstrapping.
For uncorrelated observations with variances
2 | |
\sigma | |
i |
2 | |
\sigma | |
\barx |
=
n | |
\sum | |
i=1 |
2 | |
{w | |
i' |
2 | |
\sigma | |
i} |
\sigma\bar
Consequently, if all the observations have equal variance,
2 | |
\sigma | |
i= |
2 | |
\sigma | |
0 |
2 | |
\sigma | |
\barx |
=
2 | |
\sigma | |
0 |
n | |
\sum | |
i=1 |
2}, | |
{w | |
i' |
2 | |
\sigma | |
0 |
Because one can always transform non-normalized weights to normalized weights, all formulas in this section can be adapted to non-normalized weights by replacing all
wi'=
wi | ||||||
|
Typically when a mean is calculated it is important to know the variance and standard deviation about that mean. When a weighted mean
\mu*
\hat
2 | |
\sigma | |
w |
\hat\sigma2
\begin{align} \hat\sigma2 &=
| ||||||||||
N |
\\ \hat
2 | |
\sigma | |
w |
&=
| ||||||||||
|
\end{align}
N | |
\sum | |
i=1 |
wi=1
\hat
2 | |
\sigma | |
w |
\sigma2
For small samples, 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 (see Bessel's correction). In the weighted setting, there are actually two different unbiased estimators, one for the case of frequency weights and another for the case of reliability weights.
If the weights are frequency weights (where a weight equals the number of occurrences), then the unbiased estimator is:
s2 =
| ||||||||||
|
This effectively applies Bessel's correction for frequency weights.
For example, if values
\{2,2,4,5,5,5\}
\{2,4,5\}
\{2,1,3\}
If the frequency weights
\{wi\}
s2 =
| ||||||||||
|
N | |
\sum | |
i=1 |
wi\left(xi-\mu*\right)2
where the total number of samples is
N | |
\sum | |
i=1 |
wi
N
wi
The estimator can be unbiased only if the weights are not standardized nor normalized, these processes changing the data's mean and variance and thus leading to a loss of the base rate (the population count, which is a requirement for Bessel's correction).
If the weights are instead non-random (reliability weights), we can determine a correction factor to yield an unbiased estimator. Assuming each random variable is sampled from the same distribution with mean
\mu
2 | |
\sigma | |
actual |
\begin{align} \operatorname{E}[\hat\sigma2] &=
| |||||||||
[(x |
i-\mu)2]}N\\ &=\operatorname{E}[(X-\operatorname{E}[X])2]-
1 | |
N |
\operatorname{E}[(X-\operatorname{E}[X])2]\\ &=\left(
N-1 | |
N |
\right)
2 | |
\sigma | |
actual |
\\ \operatorname{E}[\hat
2 | |
\sigma | |
w] |
&=
| ||||||||||
[(x |
i-\mu*)2]}{V1}\\ &=\operatorname{E}[(X-\operatorname{E}[X])2]-
V2 | ||||||
|
\operatorname{E}[(X-\operatorname{E}[X])2]\\ &=\left(1-
V2 | ||||||||
|
\right)
2 \end{align} | |
\sigma | |
actual |
where
V1=
N | |
\sum | |
i=1 |
wi
V2=
N | |
\sum | |
i=1 |
2 | |
w | |
i |
\left(1-
V2 | ||||||||
|
\right)
\left(
N-1 | |
N |
\right)
2 | |
V | |
1 |
/V2=Neff
1-\left(V2/
2\right) | |
V | |
1 |
The final unbiased estimate of sample variance is:
2 | |
\begin{align} s | |
w |
&=
| |||||||||
|
\\[4pt] &=
| ||||||||||
V1-(V2/V1) |
, \end{align}
2 | |
\operatorname{E}[s | |
w |
]=
2 | |
\sigma | |
actual |
The degrees of freedom of the weighted, unbiased sample variance vary accordingly from N − 1 down to 0.
The standard deviation is simply the square root of the variance above.
As a side note, other approaches have been described to compute the weighted sample variance.[6]
In a weighted sample, each row vector
xi
wi\geq0
Then the weighted mean vector
\mu* |
\mu*= |
| |||||||||
|
.
And the weighted covariance matrix is given by:[7]
C=
| ||||||||||
V1 |
.
Similarly to weighted sample variance, there are two different unbiased estimators depending on the type of the weights.
If the weights are frequency weights, the unbiased weighted estimate of the covariance matrix
styleC
C=
| ||||||||||
V1-1 |
.
This estimator can be unbiased only if the weights are not standardized nor normalized, these processes changing the data's mean and variance and thus leading to a loss of the base rate (the population count, which is a requirement for Bessel's correction).
In the case of reliability weights, the weights are normalized:
V1=
N | |
\sum | |
i=1 |
wi=1.
(If they are not, divide the weights by their sum to normalize prior to calculating
V1
wi'=
wi | |||||||||
|
Then the weighted mean vector
\mu* |
N | |
\mu*=\sum | |
i=1 |
wixi.
and the unbiased weighted estimate of the covariance matrix
C
\begin{align} C&=
| |||||||||||||||||||||
|
N | |
\sum | |
i=1 |
wi\left(xi-\mu*\right)T\left(xi-\mu*\right)\\ &=
| ||||||||||
V1-(V2/V1) |
. \end{align}
The reasoning here is the same as in the previous section.
Since we are assuming the weights are normalized, then
V1=1
C= |
| |||||||||
1-V2 |
.
If all weights are the same, i.e.
wi/V1=1/N
The above generalizes easily to the case of taking the mean of vector-valued estimates. For example, estimates of position on a plane may have less certainty in one direction than another. As in the scalar case, the weighted mean of multiple estimates can provide a maximum likelihood estimate. We simply replace the variance
\sigma2
C
The weighted mean in this case is:(where the order of the matrix–vector product is not commutative), in terms of the covariance of the weighted mean:
For example, consider the weighted mean of the point [1 0] with high variance in the second component and [0 1] with high variance in the first component. Then
x1:=\begin{bmatrix}1&0\end{bmatrix}\top, C1:=\begin{bmatrix}1&0\ 0&100\end{bmatrix}
x2:=\begin{bmatrix}0&1\end{bmatrix}\top, C2:=\begin{bmatrix}100&0\ 0&1\end{bmatrix}
then the weighted mean is:
\begin{align} \bar{x
which makes sense: the [1 0] estimate is "compliant" in the second component and the [0 1] estimate is compliant in the first component, so the weighted mean is nearly [1 1].
See also: Generalized least squares. In the general case, suppose that
X=[x1,...,x
T | |
n] |
C
xi
\bar{x}
J
[1,...,1]T
n
T | |
\sigma | |
\bar{x}=(J |
WJ)-1,
\bar{x}=
2 | |
\sigma | |
\bar{x} |
(JTWX),
where:
W=C-1.
Consider the time series of an independent variable
x
y
n
ti
y
ti
xi
z
m
zk=\sum
m | |
i=1 |
wixk+1-i.
In the scenario described in the previous section, most frequently the decrease in interaction strength obeys a negative exponential law. If the observations are sampled at equidistant times, then exponential decrease is equivalent to decrease by a constant fraction
0<\Delta<1
w=1-\Delta
m
w | ||||
|
,
V1
V1
V1=\sum
m{w | |
i=1 |
i-1
V1=1/(1-w)
m
The damping constant
w
(1-w)-1
{e-1
e-1
{1-e-1
n
\le{e-n(1-w)
n
w
The concept of weighted average can be extended to functions.[10] Weighted averages of functions play an important role in the systems of weighted differential and integral calculus.[11]
Weighted means are typically used to find the weighted mean of historical data, rather than theoretically generated data. In this case, there will be some error in the variance of each data point. Typically experimental errors may be underestimated due to the experimenter not taking into account all sources of error in calculating the variance of each data point. In this event, the variance in the weighted mean must be corrected to account for the fact that
\chi2
\hat{\sigma}\bar{x
where
2 | |
\chi | |
\nu |
2 | |
\chi | |
\nu |
=
1 | |
(n-1) |
n | |
\sum | |
i=1 |
(xi-\bar{x | |
) |
2}{
2 | |
\sigma | |
i |
};
The square root
\hat{\sigma}\bar{x
When all data variances are equal,
\sigmai=\sigma0
\sigma\bar{x
\sigma\bar{x
\sigma2=
| ||||||||||
) |
2}{n-1}.