Azzera filtri
Azzera filtri

Polyfitn Function calculate the RMS value

3 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

John D'Errico
John D'Errico il 22 Ott 2016
Modificato: John D'Errico il 22 Ott 2016
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.
  1 Commento
jupiter
jupiter il 24 Ott 2016
Thank you John, while I was also doing the same thing but calculating the sum and then dividing it by the number of elements (Old school way :)), only a factor of cube at the denominator was causing the difference in the result. Now everything is working fine.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Chemistry in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by