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?
조회 수: 1 (최근 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!