如何在 Matlab 中计算 'compare' 函数
How to calculate 'compare' funtion in Matlab
我正在研究均方根误差 (RMSE) 和归一化均方根误差 (NRMSE)。
根据Wikipedia's article and according to Matlab's function。
为什么 Wikipedia 手动 NRMSE 和 MATLAB compare
代码 NRMSE 的 NRMSE 值不同?
你能教我如何计算 compare
函数吗?
例如,我制作如下。维基百科的方法:
Vt = 1:11;
V1 = [11.5 7.6 6.7 8.3 7.7 7.4 6.5 5.6 6.6 11.2 11.9]; % obseved data
V2 = [11.9 10.8 8.3 9.6 11.4 10.2 12.4 9.6 8.3 8 9]; % estimationd data
RMSE = sqrt(mean((V1-V2).^2)); % RMSE = 3.14107
NRMSE = RMSE/(max(V2)-min(V2)) % NRMSE = 0.71
MATLAB内部比较函数:
% to use compare
VV1 = iddata(V1', Vt');
VV2 = iddata(V2', Vt');
compare(VV1,VV2) % -48.46%
根据compare
文档,Matlab对NRMSE的估计与你的不一样。
你要知道计算RMSE和NRMSE的方法有很多种。来自您在 Root-mean-square deviation 上链接的维基百科文章:
there is no consistent means of normalization in the literature.
你选择了一种方式,Matlab 有另一种方式。
所以如果你想匹配Matlab的结果,你应该这样做:
NRMSE = 100*(1 - norm(V1-V2)/norm(V1-mean(V1)))
[y,fit,x0] =compare(VV1,VV2); fit
这个returns
NRMSE =
-48.4595
fit =
-48.4595
我正在研究均方根误差 (RMSE) 和归一化均方根误差 (NRMSE)。
根据Wikipedia's article and according to Matlab's function。
为什么 Wikipedia 手动 NRMSE 和 MATLAB compare
代码 NRMSE 的 NRMSE 值不同?
你能教我如何计算 compare
函数吗?
例如,我制作如下。维基百科的方法:
Vt = 1:11;
V1 = [11.5 7.6 6.7 8.3 7.7 7.4 6.5 5.6 6.6 11.2 11.9]; % obseved data
V2 = [11.9 10.8 8.3 9.6 11.4 10.2 12.4 9.6 8.3 8 9]; % estimationd data
RMSE = sqrt(mean((V1-V2).^2)); % RMSE = 3.14107
NRMSE = RMSE/(max(V2)-min(V2)) % NRMSE = 0.71
MATLAB内部比较函数:
% to use compare
VV1 = iddata(V1', Vt');
VV2 = iddata(V2', Vt');
compare(VV1,VV2) % -48.46%
根据compare
文档,Matlab对NRMSE的估计与你的不一样。
你要知道计算RMSE和NRMSE的方法有很多种。来自您在 Root-mean-square deviation 上链接的维基百科文章:
there is no consistent means of normalization in the literature.
你选择了一种方式,Matlab 有另一种方式。
所以如果你想匹配Matlab的结果,你应该这样做:
NRMSE = 100*(1 - norm(V1-V2)/norm(V1-mean(V1)))
[y,fit,x0] =compare(VV1,VV2); fit
这个returns
NRMSE =
-48.4595
fit =
-48.4595