matlab - 如何在 Matlab 中计算“比较”功能
问题描述
我正在研究均方根误差 (RMSE) 和归一化均方根误差 (NRMSE)。
为什么 Wikipedia 手动 NRMSE 和 MATLAB 代码 NRMSE 之间的 NRMSE 值不同compare
?
你能教我如何用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上链接的 Wikipedia 文章中:
文献中没有一致的标准化方法。
你选择了一种方式,而 Matlab 有另一种方式。
所以如果你想匹配 Matlab 的结果,你应该这样做:
NRMSE = 100*(1 - norm(V1-V2)/norm(V1-mean(V1)))
[y,fit,x0] =compare(VV1,VV2); fit
这返回
NRMSE =
-48.4595
fit =
-48.4595
推荐阅读
- python - 我是否能够将目录路径转换为可以输入 python hdf5 数据表的内容?
- figma-api - Figma 不加载 .fig 文件
- django-rest-framework - 如何在Django rest框架中获取外键的名称
- javascript - 使用 Angular 从 Firestore 数据库返回多个集合
- javascript - 如何使用 javascript 进行搜索和过滤
- kotlin - 如何按 Arraylist 多维分组
- html - 从 html 接收表单数据的简单方法
- angular - SharedModule 服务构造函数被多次调用
- r - 在 R 中创建额外的行
- mysql - 基于同一张表获取 3 列左连接