# Calculate standard deviation of merged sets with limited information (full details inside)

I have:
A1: {3, 5, 6} and A2: {3, 4, 6, 8}

Avg A1: 4.(6)
Std.Deviation A1: 1.247

Avg A2: 5.25
Std. Deviation A2: 1.92

Merging A1 and A2, we get
A12: {3, 3, 4, 5, 6, 6, 8}

Avg A12: 5
Std. Deviation A12: 1.69

I want to be able to obtain those values (avg and std. deviation for A12), having only the following information about A1 and A2:

A1
No. Elements: 3
Avg A1: 4.(6)
Std.Deviation A1: 1.247

A2
No. Elements: 4
Avg A2: 5.25
Std.Deviation A2: 1.92

Average is easy, (4.(6)*3 + 5.25*4)/7 = 5

But I seem to be unable to calculate the correct std. deviation value. I can only use the above information. Any ideas?

-
How do you get standard deviations of 1.11, 1.75 and 1.4286? They look rather low. – Henry Feb 17 '11 at 12:36
oops, you are right, it is not. Awful mistake. will edit it now – baderous Feb 17 '11 at 14:23

If $\sigma$ is the (population) standard deviation then

$$\sigma^2 = \frac{\sum (x_i - \mu)^2}{n} = \frac{\sum x_i^2}{n} - \mu^2$$

so using the subscripts $1$, $2$ and $C$ for the first part, second part and combination

$$\sigma_C^2 = \frac{n_1 (\sigma_1^2 + \mu_1^2) + n_2 (\sigma_2^2 + \mu_2^2)}{n_1+n_2} - \mu_C^2$$

where $\mu_C = \frac{n_1 \mu_1 + n_2 \mu_2}{n_1+n_2}$ as you have. Then take the square root.

I think this is easier to understand than Wikipedia's version though theirs is better if rounding errors are an issue (e.g. with large means close to each other and small standard deviations).

-
it definitely is! thank you. :) – baderous Feb 17 '11 at 15:42