How to fit a quadratic function using the "minimizing the volume-weighted mean squared error"?

2 visualizzazioni (ultimi 30 giorni)
Say I have a function y = a + b*x + c*x.^2 and I got matrixes x and y, and the weight w.
Estimate the parameters ( a, b and c) by minimizing the volume-weighted mean squared error?
i.e. to minimize [ sum (w. * ( y - yhat ).^2) / (sum w) ]

Risposta accettata

Siyu Guo
Siyu Guo il 30 Apr 2018
Modificato: Siyu Guo il 30 Apr 2018
u = sqrt(w(:));
b1 = u;
b2 = u.*x(:);
b3 = u.*x(:).^2;
f = u.*y(:);
A = [dot(b1,b1) dot(b1,b2) dot(b1,b3);
dot(b1,b2) dot(b2,b2) dot(b2,b3);
dot(b1,b3) dot(b2,b3) dot(b3,b3)];
v = [dot(b1,f); dot(b2,f); dot(b3,f)];
p = A\v; % p(1) = a, p(2) = b, p(3) = c
Hope I haven't made mistakes. :)
  8 Commenti
John D'Errico
John D'Errico il 30 Apr 2018
I admit that I often seem to be ranting about the use of a few numerical methods, taught by textbooks, by teachers, in courses, etc. The problem is that numerical analysis has changed relatively rapidly over the last 50 years. We have learned much in that time. But there are still bad memes that propagate, and never seem to die out. The problem is that students are taught a bad numerical method. They are taught that by a teacher who learned the same thing, from a textbook or paper written by someone who did not know any better. And then the student grows up, into a teacher, a mentor, etc. What do they tell their own students? Of course, they teach what they know as "truth". That it is provably poor is irrelevant. But these memes propagate forever. Taught from one person to another by word of mouth, by text. etc.
It never stops unless someone is out there, trying to intercept the bad ideas from propagating, explaining why they are actively bad, and explaining that there is a good solution.
So I tilt at windmills...

Accedi per commentare.

Più risposte (1)

Iris Li
Iris Li il 1 Mag 2018
Thanks you two! I made some silly comments but learned a lot. :)

Community Treasure Hunt

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

Start Hunting!

Translated by