Exponentially Weighted Moving Average (EWMA)
조회 수: 45 (최근 30일)
이전 댓글 표시
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개)
Voss
2024년 4월 3일
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.')
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!