-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnrmse.m
24 lines (21 loc) · 950 Bytes
/
nrmse.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function NRMSE = nrmse( output, target)
% Computes normalized root mean square error.
%
% Input arguments:
% - output, target: two time series of equal dim and length, format
% dim x timepoints
%
% Outputs:
% - nmse: normalized mean root square error (in column vector)
%
% Created by Mantas Lukosevicius
% Rev 1, April 21 2008, HJaeger: changed ./ targVar in computation of nmse
% to / mean(targVar) to avoid Inf in case
% of all-zero rows in target
% Rev 2, Aug 23, 2008 HJaeger: input format of output and input has
% now time in rows
% Rev 3, May 02 2009 HJaeger: division by target variance is now again
% dim-wise, Inf outputs are now possible again
combinedVar = 0.5 * (var( target, 0, 2 ) + var( output, 0, 2 ));
errorSignal = ( output - target );
NRMSE = sqrt( mean( errorSignal .^ 2, 2 ) ./ combinedVar );