# Weighted mean from data [closed]

Suppose we have 3 experimental groups measuring "x", they measure

$$x_1=\mu_1\pm \sigma_1$$

$$x_2=\mu_2\pm \sigma_2$$

$$x_3=\mu_3\pm \sigma_3$$

In the 3 experiments, we have done N measurements of "x". We do know that we have the best estimate of "x" weighting the three means or averages $\mu_i$ with the variance. But, suppose we provide a statistical "weight" (probability or reliability) of those 3 values, e.g. 0.25, 0.50 and 0.25 to the first, second and third. More generally, we give weights or probabilities $w_i$ to those calculations. How can we calculate the right weighted mean including both, variance and the probabilistic weights $w_i$? How does the solution change if we have different sample sizes in the 3 different experiments, i.e., how is the solution modified when we have sizes $N_1, N_2, N_3$ in the 3 experiments instead of the same number N of observations/measurements?

Remark: I have written the error in the mean/average as $\sigma_i=s_i/\sqrt{N}$

## closed as off-topic by ja72, Brandon Enright, BMS, Martin, JamalSDec 18 '14 at 21:55

• This question does not appear to be about physics within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• What is your definition of statistical weight in this context? – ACuriousMind Dec 18 '14 at 17:11
• Cross Validated, which is the statistics SE, is probably a better home for this question. – BMS Dec 18 '14 at 19:46
• This question appears to be off-topic because it is free of physics and is best suited for stats.stackexchange.com – BMS Dec 18 '14 at 19:47

The weighted mean of three values is given by $$\bar{x} = \frac{ \sum_{i=1}^{3} x_i \alpha_i}{\sum_{i=1}^{3} \alpha_i},$$ where here $\alpha_i$ represents the weight that you give to each measurement.

If you wished to just find the weighted mean from your data as you presented it originally, then the weight $\alpha_i = 1/\sigma_i^{2}$.

If you then wish to insert additional arbitrary weightings, $w_i$ to each point then the weights will multiply each other. i.e. $\alpha_i = w_i/\sigma_i^{2}$.

Here I am making the assumption that this is what you mean by a "weight" and not that there is some extra systematic uncertainty in the measurements that is shared in the proportions you suggest between the three measurements. If that were the case then you would form the weight by adding the appropriate systematic error in quadrature with $\sigma_i$.

As to the last part of your question I am a bit puzzled. If you are using the fact that $\sigma_i = s_i/\sqrt{N}$ (I assume $s_i$ is the standard deviation of the population right?), then the possibility of different sample sizes is already incorporated into this formula - the experiment that take a larger number of measurements will presumably return a smaller value of $\sigma$ (if $s$ stays the same).

• Yes, I used a bad notation with the standard deviation. Just an additional question, Rob Jeffries. Suppose the same 3 experiments. Suppose we want to combine the three samples of order N of the same statistic in the following way: you weight the first with 1/6, the second with 2/6 and the third with 3/6, what is the best estimate of the average of the statistic $$Y=1/6x_i+2/6y_i+3/6z_i$$, where $x_i, y_i, z_i$, with i=1,..., N are the measurements of the 3 teams (those which give $x_1,x_2,x_3$. Would it (and why) be Ok if we calculate the average and standard deviation of those combinations? – riemannium Dec 14 '14 at 11:42
• @riemannium I am not clear how this relates to the question I have answered. Perhaps you should ask it as a new question? If $x$, $y$ and $z$ are supposed to be measurements of the same thing in different experiments, then of course you can weight them however you wish. – Rob Jeffries Dec 14 '14 at 19:39
• $x_i, y_i, z_i$ are 3 differents order N-samples measuring a same quantity. $x_i, y_i, z_i$ have different averages and standard deviations, the question is: what is the best combined average and its (statistical) error? Should we combine in quadrature the 3 $s_i/\sqrt{N}$? – riemannium Dec 18 '14 at 18:06

The way that I would approach this is to calculate $\chi^2$ with

$$\chi^2 = \sum_{i=1}^N\left({p - x_i \over \sigma_i}\right)^2$$

where $p$ is the best value for the fit and $N$ is the number of measurements $x_i$ with error $\sigma_i$.

Now with a computer or Excel sheet I would plot $\chi^2$ as a function of $p$.

As you know the value of $p$ for the lowest value of $\chi^2$, which we refer to as ${\chi_{min}^2}$, is the best fit.

To get the uncertainty you look to see the range of $p$ values for which $$\chi^2 <{\chi_{min}^2} + 1$$

This will give you the range for your error bars for $p$.

This is a good general method for fitting data, but it gets more complicated when you fit more than one parameter and parameters can depend on each other. A good place for more information about this is the Numerical Recipes Book by Press, Teukolsky $et al.$ and here on the web

• Formula for chi squared is incorrect! – Rob Jeffries Dec 14 '14 at 9:27
• @RobJeffries sorry - many apologies - fixing it now! – tom Dec 14 '14 at 12:23
• I refer you to the advice at the end of your answer. Chi-squared is the sum of $(p-x_i)^2/\sigma_i^{2}$. Reduced chi-squared is that divided by the number of degrees of freedom (is that what your undefined $n$ is?). The formula you have referred to for an error estimation uses the unreduced chi-square though - so there are still two mistakes here. – Rob Jeffries Dec 14 '14 at 12:36
• @RobJeffries - at last I think I finally got this straightened out - thank you for your comments and guidance on this, I really appreciate it. - ( do let me know if I stil have messed it up somewhere) – tom Dec 14 '14 at 16:57