# Here’s how to calculate the root mean square error.

Assume you have one set of numbers that represent the **Actual** values you want to predict.

Actual = [1 2 3 4]; |

Then assume you have another set of numbers that **Predicted** the actual values.

Predicted = [1 3 1 4]; |

How do you evaluate how close **Predicted** values are to the **Actual** values?

Well you could use the root mean square error (RMSE) to give a sense of the **Predicted** values error.

Here’s some MATLAB code that does exactly that.

% rmse tutorial. % The actual values that we want to predict. Actual = [1 2 3 4]; % The values we actually predicted. Predicted = [1 3 1 4]; % One way is to use the Root Mean Square function and pass in the "error" part. rmse = rms(Predicted-Actual) % That's it! You're done. % But for those of you who are the curious type, % here's how to calculate the root-mean-square-error by hand. % First calculate the "error". err = Actual - Predicted; % Then "square" the "error". squareError = err.^2; % Then take the "mean" of the "square-error". meanSquareError = mean(squareError); % Then take the "root" of the "mean-square-error" to get % the root-mean-square-error! rootMeanSquareError = sqrt(meanSquareError) % That's it! You have calculated the RMSE by hand. % So, this is true. rootMeanSquareError == rmse |

How can i get a predicted values? Im doing GM(1,1) and dont know how to get a predicted data/value

What’s GM(1,1)? The predicted values would come from some model you have. I just made them up for this example.

I actually figured out that i was doing it wrong… -.-”

Thanks anyway!

Glad you figured it out Ângelo!

Using MATLAB’s rms() gives me a diferent result from your calculation. Any idea why?

Thanks!

Thanks!