blob: 29f4ebd59d0d9d6e30eff9da401bc3d1a65fc063 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
//Caption:Weighted Moving Average Method
//Example10.6
//Page383
clear;
clc;
Dt = [80,90,70,100,70,90];//Demand of a product
t = length(Dt);// months
W = [0.2,0.3,0.5];//weights
//Three months weighted moving averages
for i = 3:t
Wt(i-2) = W*Dt([(i-2):i])' ;
WtMA(i-2) = Wt(i-2)/sum(W)
end
disp(WtMA,'Three Months weighted moving average Mt=')
for i = 1:length(Wt)-1
Ft(i) = WtMA(i);
et(i) = Dt(i+3)-Ft(i);
end
disp(Ft,'Forecast Ft=')
disp(et,'Error et=')
MAD = sum(abs(et(:)))/length(et);
disp(MAD,'Mean Absolute Deviation MAD=')
MFE = sum(et(:))/length(et);
disp(MFE,'Mean Forecast Error MFE=')
//Result
//Three Months weighted moving average Mt=
//
// 78.
// 89.
// 79.
// 86.
//
// Forecast Ft=
//
// 78.
// 89.
// 79.
//
// Error et=
//
// 22.
// - 19.
// 11.
//
// Mean Absolute Deviation MAD=
//
// 17.333333
//
// Mean Forecast Error MFE=
//
// 4.6666667
|