52matlab技术网站,matlab教程,matlab安装教程,matlab下载

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 8173|回复: 0
打印 上一主题 下一主题

分享一个MATLAB计算RMSE

[复制链接]

1

主题

1

帖子

17

积分

新手上路

Rank: 1

积分
17
跳转到指定楼层
楼主
发表于 2016-6-21 11:28:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
抄自mathworks

function r = rmse(prediction,estimate)
% generalized function from Felix Heder http://www.mathworks.com/matlabc ... rmse/content/rmse.m
% Function to calculate root mean square error from a prediction vector or matrix
% and the corresponding estimates.
% Usage: r = rmse(data,estimate)
% Note: predictions and estimates have to be of same size or estimate can be one
% number
% Example: r = rmse(randn(100,100),randn(100,100)) or r = rmse(randn(100,100),0)

if numel(estimate) == 1 && numel(prediction) > 1
    % delete records with NaNs in data first
    I = ~isnan(prediction);
else
    % delete records with NaNs in both datasets first
    I = ~isnan(prediction) & ~isnan(estimate);
    estimate = estimate(I);   
end
prediction = prediction(I);
r = sqrt(mean((prediction(-estimate().^2));



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|52matlab技术网站 ( 粤ICP备14005920号-5 )

GMT+8, 2024-4-26 23:31 , Processed in 0.088704 second(s), 19 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表