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

4 次查看(过去 30 天)
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) ]

采纳的回答

Siyu Guo
Siyu Guo 2018-4-30
编辑:Siyu Guo 2018-4-30
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 个评论
John D'Errico
John D'Errico 2018-4-30
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...

请先登录,再进行评论。

更多回答(1 个)

Iris Li
Iris Li 2018-5-1
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