Exponentially Weighted Moving Average (EWMA)
61 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello community, kindly let me ask for your help one more time.
I'm trying to apply this EWMA formula to my data:
EWMA(t) = a * x(t) + (1-a) * EWMA(t-1)
where :
a = the weight decided by the user
x = value of the series in current period
My data is:
EWMA(initial value) = 0.3
a = 0.3
x = [ .15 .11 .11 .1 .09 .12 .11 .09];
using the formula and above values I will get this:
EWMA = 0.3 * 0.15 + (1 - 0.3) * EWMA(initial value) 0.3 = 0.255
then I need to apply the formula to all my data but now using previous EWMA value EWMA(t-1), calculated above
EWMA = 0.3 * 0.11 + (1 - 0.3) * 0.255 = 0.2115
EWMA = 0.3 * 0.11 + (1 - 0.3) * 0.2115 = 0.18105
EWMA = 0.3 * 0.1 + (1 - 0.3) * 0.18105 = 0.1516735
EWMA = 0.3 * 0.09 + (1 - 0.3) * 0.156735 = 0.136714
EWMA = 0.3 * 0.12 + (1 - 0.3) * 0.136714 = 0.131700
EWMA = 0.3 * 0.11 + (1 - 0.3) * 0.131700 = 0.125190
EWMA = 0.3 * 0.09 + (1 - 0.3) * 0.125190 = 0.114633
any recomendation will be higly appreciated.
1 comentario
Respuestas (1)
Voss
el 3 de Abr. de 2024
Here's how you can perform the calculations you've listed:
% given:
a = 0.3;
x = [0.15 0.11 0.11 0.1 0.09 0.12 0.11 0.09];
N = numel(x);
EWMA = zeros(1,N+1);
EWMA(1) = 0.3; % given
for ii = 2:N+1
EWMA(ii) = a * x(ii-1) + (1-a) * EWMA(ii-1);
end
format long g
disp(EWMA.')
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!