-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest.m
More file actions
29 lines (29 loc) · 767 Bytes
/
test.m
File metadata and controls
29 lines (29 loc) · 767 Bytes
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
function [MAPE, RMSE] = test(forecast, load_demand)
%
% This file includes code for the paper Probabilistic Load Forecasting based on Adaptive Online Learning.
% @author: Verónica Álvarez
%
% This function quantifies the prediction errors root mean square error (RMSE) and mean average percentage error (MAPE)
%
% Inputs
% Forecast is a vector of load forecasts
% load_demand is a vector of load corresponding with load forecasts
%
% Outputs
% MAPE
% RMSE
%
m = [];
r = [];
n = length(forecast);
for i = 1:n
if load_demand(i) > 0
% MAPE
m(i) = abs((load_demand(i) - forecast(i))/load_demand(i));
% RMSE
r(i) = (load_demand(i) - forecast(i))^2;
end
end
MAPE = 100*nanmean(m);
RMSE = sqrt(nanmean(r));
end