


Instead, you need to use the last method. You generate your data from frequencies, but it's not a simple matter of having 45 records of 3 and 15 records of 4 in your data set. In your case, it superficially looks like the weights are frequencies but they're not. you are just trying to avoid adding up your whole sum), if the weights are in fact the variance of each measurement, or if they're just some external values you impose on your data. In particular, you will get different answers if the weights are frequencies (i.e. The key is to notice that it depends on what the weights mean.

The formulae are available various places, including Wikipedia.
