Correct way to calculate Moving Mean for Ozone hourly values

21 visualizzazioni (ultimi 30 giorni)
Hello guys.
I have trouble understanding various "versions" of movmean. What I want to do is calculate moving mean with 8-hour interval from hourly ozone observations (see sample attached file).
Can anyone please explain what is the difference between
1) O3_movAv = movmean(data.O3,[0,8],'omitnan');
2) O3_movAv = movmean(data.O3, 8, 2, 'omitnan');
3) O3_movAv = movmean(data.O3,[8,0],'omitnan');
The output is different among these 3? Which is the correct one for my dataset?
Thank you in advance!

Risposta accettata

dpb
dpb il 27 Lug 2021
1, 3. "movmean(A,[kb kf]) computes the mean with a window of length kb+kf+1 that includes the element in the current position, kb elements backward, and kf elements forward."
So 1) is "leading" average of 0 points back and 8 points forward, 3) is "trailing" average of 8 points back and 0 points forward
2. "movmean(A,k) returns an array of local k-point mean values, where each mean is calculated over a sliding window of length k across neighboring elements of A. When k is odd, the window is centered about the element in the current position. When k is even, the window is centered about the current and previous elements. ... movmean(___,dim) returns the array of moving averages along dimension dim for any of the previous syntaxes. For example, if A is a matrix, then movmean(A,k,2) operates along the columns of A, computing the k-element sliding mean for each row."
So, 2 is moving average of 8 points over the 8 points about the given position as described along the 2nd dimension of the array -- which would have to be a row vector in your case, making it a superfluous input.
4) They're all "correct"; just averaging over different sets of elements. Which is appropriate for your use (if any) is totally dependent upon what the intended use of the result is for. Only you can decide that...
  3 Commenti
Daphne PARLIARI
Daphne PARLIARI il 28 Lug 2021
Steven thanks for your contribution!
I can't quite understand the SamplePoints concept... What does " movmean(A, [kb, kf], 'SamplePoints', t) will not treat kb and kf as a number of elements but a distance in the SamplePoints vector." mean exactly?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by