Calculating RMSE between observations and estimates of different number of data points

8 次查看(过去 30 天)
I want to calculate RMSE using observed data that was sampled at 2000 hz for 12 seconds ( 24,000 data points) and estimate data which is at 50 hz ( 600 data points). I want to keep the resolution I have for the collected data so I don't want to down sample observed data.
How can I go about getting the same number of data points for observed and estimate values in order to calculate RMSE for this data?
Thank you.

回答(1 个)

Christiaan
Christiaan 2015-3-10
Dear Chanah,
If I understand you correctly, you performed a measurement of 12 seconds. During those 12 seconds you have 'estimated data' and 'observed data'. The estimated data has 600 points and the collected/observed data has 24000 data points.
Now you would like to calculate the RMSE between your estimated and collected data points. However, since the definition of the RMSE is the error between two points at the same time, from the pure mathematical point of view only the 600 data points can be used.
However what could be done in matlab is using a spline to calculate the 'expected' data points and then calculate with all 24000 data points the RMSE. Herefore the function pchip can be used. This code can illustrate this:
clc;clear all;close all;
% create observed data -> use your own data here
time_observed = linspace(1/2000,12,2000*12);
y_observed = sin(time_observed);
% create estimated data -> use your own data here
time_estimated = linspace(1/50,12,50*12);
for i=1:length(time_estimated)
y_estimated(i) = sin(time_estimated(i))+randn()*0.1;
end
% create extended estimated data
for i=1:length(time_observed)
y_estimated_extended(i) = pchip(time_estimated,y_estimated,time_observed(i));
end
% calculate RMSE
RMSE = sqrt(mean((y_observed - y_estimated_extended).^2))
figure(1)
subplot(2,1,1)
plot(time_observed,y_observed,'.',time_estimated,y_estimated,'x');grid on;
title('observed data and not interpolated estimated data')
subplot(2,1,2)
plot(time_observed,y_observed,'.',time_observed,y_estimated_extended,'x'); grid on;
title('observed data and interpolated estimated data')
Good luck! Christiaan

类别

Help CenterFile Exchange 中查找有关 Splines 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by