Suppose we have a set of number {x1,x2,...,xn} and we would like to estimate its sum s=∑ixi.
However, we can only access the set {x1,x2,...,xn} by sampling an element xi,1≤i≤n randomly.
Let pi be the probability that we get xi.
If pi is known (either before sampling or the moment we get a sampled element, depending on application), then we can still construct an unbiased estimator of s:
define
yi=pixi,
and let Y be the random variable that takes value yi with probability pi.
The expectation and variance of Y is given by
It can be seem that the variance of Y is minimized when pi=sxi for all i.
In such case, yi=xi/(xi/s)=s is a constant and Var[Y]=0 (which is the smallest variance possible as its must be non-negative).
Remark: we can also verify this by formulating this as an optimization problem then using Lagrangian method.
In some applications, some elements in {x1,x2,...,xn} may have same value. Suppose there are m different value in {x1,x2,...,xn} and define Xj(1≤j≤m) the set of elements with the j-th largest value. Denote the sum of probability of elements in Xj as Prj=∑x∈Xjpx. Also, let f(xi) denote the group that element xi belongs to, i.e., xi∈Xf(xi). Consider
yi′=Prf(xi)xi∣Xf(xi)∣,
and Y′ a random variable that takes value yi′ with probability pi. The mean of Y′ is also an unbiased estimator of s: