Standard Deviation for X,Y data over 30 Years
조회 수: 4 (최근 30일)
이전 댓글 표시
I have 30 years of monthly average temperature for global latitude/longitude in a matrix A (dimensions Y,X,Year; size 361,721,30). I want to compute the standard deviation for each lat/long over the 30-year period so the resulting matrix should be size (361,721).
I've tried std(A,[],3) but the standard deviation isn't correct. Any thoughts on what I'm doing wrong or how to do this using the STD function?
댓글 수: 2
dpb
2023년 7월 2일
What makes you think the result of std is in error? I've never had it fail...sometimes there are ~isfinite() values or other bogus data that can fool you, but that's not the fault of std
Attach enough to show us what isn't what you think it should be; the obvious way would be to attach the .mat file of your data...
dpb
2023년 7월 2일
편집: dpb
2023년 7월 2일
A=randi(100,5,5,5);
S1=std(A,[],3)
S2=std(A,0,3)
std(A(1,1,:))
v=squeeze([A(1,1,:)]);v=v-mean(v);
sqrt(dot(v,v)/(numel(v)-1))
sqrt(v.'*v/(numel(v)-1))
Shows it all seems to work as expected. I noticed the doc stated to use the 0 weight argumet explicitly so just checking that [] did as expected (sure it would) as well...
답변 (1개)
the cyclist
2023년 7월 2일
std(A,[],3)
which seems to be equivalent to
std(A,0,3)
gives you normalization by N-1, which would typically what you want for sampled data. If instead you wanted normalization by N (typically for population data), then you can do
std(A,1,3)
instead. But I expect that is not the issue you mean.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!