MATLAB: Standard deviation of values with standard deviation

meanstandard deviationstd of std

Hello,
Let's say I have the follwing sample (the error values correspond to the std) :
10 +- 1
15 +- 2
20 +- 3
I want to calculate the average value and the standard deviation. The mean of the [10,15,20] is 15 with std = 4.1 disregarding the individual stds.
How would I calculate the average of the sample and the std taking inti account the individual stds??
Thank you,
Andreas

Best Answer

The question you are asking is a specific instance of "propagation of uncertainty". You might want to learn more about the topic.
For this specific case, I believe the answer is
std_sum = sqrt(1^2 + 2^2 + 3^2); % error of sum = square root of (sum of squares of individual uncertainties)
std_mean = std_sum/3
std_mean = 1.2472
Here is a simulation that suggests that this is correct:
rng default
N = 100000;
x1 = 10 + 1*randn(N,1);
x2 = 15 + 2*randn(N,1);
x3 = 20 + 3*randn(N,1);
x = [x1, x2, x3];
mean_x = mean(x,2);
mean(mean_x)
ans = 15.0007
std(mean_x,1)
ans = 1.2459
figure
subplot(4,1,1), histogram(x(:,1))
xlim([0 30])
subplot(4,1,2), histogram(x(:,2))
xlim([0 30])
subplot(4,1,3), histogram(x(:,3))
xlim([0 30])
subplot(4,1,4), histogram(mean_x)
xlim([0 30])
I would encourage you to be really careful about your terminology. Often when people write x +/- dx, dx refers to the standard error, not the standard deviation. The standard deviation is a property of the parent population. The standard error (of the mean, for example) will depend on the sampling -- specifically on sample size.
I think that what I have written above probably corresponds to what you wanted to know, but be careful.
Related Question