I have calculated 4 standard deviation values for each row of a 4x3 matrix. How to convert these 4 values into a single standard deviation value for the whole matrix?
2 次查看(过去 30 天)
显示 更早的评论
a=[2 3 5;12 67 54;3 7 8;14 9 23]
b= std(a,0,2)
1 个评论
Rik
2023-6-24
The standard deviation of a large set can only be estimated from the standard deviations of the parts. Are you sure you want to do that instead of calculating the SD for all values?
回答(3 个)
John D'Errico
2023-6-24
编辑:John D'Errico
2023-6-24
You should understand why it is not possible to compute the overall standard deviation, merely from the pieces. This is because a standard deviation does not contain information about the mean. That information has essentially been lost to the world. Dumped in the laundry basket of computing, never to be seen again. ;-)
Let me give an example. Consider a case where we have two groups of numbers. I'll call them X and Y.
X = normrnd(0,2,[1,5])
Y = normrnd(5,4,[1,5])
We can compute the standard deviation of X and Y. That part is easy.
stdX = std(X)
stdY = std(Y)
But if you look at the formula for standard deviation, it first subtracts the mean of the set. I'll write it here as a function handle.
S = @(Z) sqrt(sum((Z - mean(Z)).^2/(numel(Z)-1)))
S(X)
Wow! I got it right! But the problem is, unless you know the original means of the subgroups, you cannot infer what the standard deviation of the aggregate group would be. So you can do this:
std([X,Y])
That is the equivalent to what others have suggested, which is to create one large vector of data from the array, and then compute the global standard deviation.
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!