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

2 Ansichten (letzte 30 Tage)
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) ]

Akzeptierte Antwort

Siyu Guo
Siyu Guo am 30 Apr. 2018
Bearbeitet: Siyu Guo am 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 Kommentare
John D'Errico
John D'Errico am 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...
Siyu Guo
Siyu Guo am 1 Mai 2018
I'm looking forward to a numeric methods textbook written by you, :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Iris Li
Iris Li am 1 Mai 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