Home > custom > math > rmse.m

rmse

PURPOSE ^

Function to calculate root mean square error from a data vector or matrix

SYNOPSIS ^

function r=rmse(data,estimate)

DESCRIPTION ^

 Function to calculate root mean square error from a data vector or matrix 
 and the corresponding estimates.
 Usage: r=rmse(data,estimate)
 Note: data and estimates have to be of same size
 Example: r=rmse(randn(100,100),randn(100,100));

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function r=rmse(data,estimate)
0002 % Function to calculate root mean square error from a data vector or matrix
0003 % and the corresponding estimates.
0004 % Usage: r=rmse(data,estimate)
0005 % Note: data and estimates have to be of same size
0006 % Example: r=rmse(randn(100,100),randn(100,100));
0007 
0008 % delete records with NaNs in both datasets first
0009 I = ~isnan(data) & ~isnan(estimate); 
0010 data = data(I); estimate = estimate(I);
0011 
0012 r = sqrt( sum( (data(:)-estimate(:)).^2) / numel(data) );
0013

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003