Standard Deviation for X,Y data over 30 Years
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
dpb
am 2 Jul. 2023
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
am 2 Jul. 2023
Bearbeitet: dpb
am 2 Jul. 2023
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...
Antworten (1)
the cyclist
am 2 Jul. 2023
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 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!