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!