Why are these two RMSE yield different results?

LM_error= sqrt(mean(((trueLm-estLm).^2),2));
LM_error= sqrt(sum(((trueLm-estLm).^2),2)/length(data));

Answers (1)

Image Analyst
Image Analyst on 8 Apr 2018
Edited: Image Analyst on 8 Apr 2018
Why should they be? The first method does not even use the array called data at all so it doesn't surprise me that they are different.
And why not simply use immse()?

5 Comments

But is "mean" not the "average"? where we add up all the numbers and then divide by the number of elements
The mean is the average. But you're not dividing by the number of points. You're dividing by length of data. We don't even know what data is, but anyway, length() of a 2-D array is the size of the longest dimension. Not sure you knew that.
The total of trueLM (true Landmarks) and estLM(estimated Landmarks) are the same same as the length of the data.
Let's change it to Robot Position. The total number of trueRP and estRP are the same as length of the data.
My data is the total number of the cells which in each cells (time step) has one true Robot Position and one estimated Robot Position. If I have to sum all of their substractions, then square it, and when I want to take the mean, shouldn't the sum(x)/length(data) same as the mean(x)?
Because total number of x is the same as length(x).
Not necessarily, but sum(x)/length(x) IS the same as mean(x)?
Thank you
But I am still wondering why the results I got are different to each other. The sum((trueLM-estLM).^2)/length(x)

Sign in to comment.

Products

Tags

Community Treasure Hunt

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

Start Hunting!