Polyfitn Function calculate the RMS value
3 次查看(过去 30 天)
显示 更早的评论
When I use 'polyfitn' function to fit 3D data, should I use 'polyvaln' function and calculate the RMS error? OR Can I directly consider the RMSE value from the function 'polyfitn' to be the RMS error. In both the cases, the values are different. But for all the cases I checked, the minima occurs at the same point for both the values. Is it safe to consider RMSE value?
0 个评论
采纳的回答
John D'Errico
2016-10-22
编辑:John D'Errico
2016-10-22
You can find the formula for RMSE easily enough. Here for example:
https://en.wikipedia.org/wiki/Root-mean-square_deviation
It is simply the sqrt of the mean of the squares of the errors, which is what polyfitn computes, as you can see:
polymodel.RMSE = sqrt(mean((depvar - yhat).^2));
So, you may have chosen a different formula for RMSE. I suppose there are others one might define, but the one in polyfitn is what seems to be standard.
I have no idea what you are asking about if it is safe to use the RMSE that polyfitn returns.
As a simple test:
M = rand(10,3);
y = rand(10,1)*10 + 10;
P = polyfitn(M,y,1);
pred = polyvaln(P,M);
sqrt(mean((pred - y).^2))
ans =
1.9747
P.RMSE
ans =
1.9747
I'm not sure what form you might have chosen here otherwise.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!