Reply to topic

Polynomial fitting using L1-norm

User avatar dzenanz
Registered Member
Posts
35
Karma
0
OS

Polynomial fitting using L1-norm

Mon Jun 10, 2013 3:04 pm
I currently use Eigen for Polynomial fitting using L2 norm (least squares fitting), like this:
Code: Select all
Eigen::MatrixXd A(points.size(), degree+1);
for (int i=0; i<points.size(); i++)
{
    double xik=1;
    for (int k=0; k<=degree; k++)
    {
        A(i,k)=xik;
        xik*=points[i]->x;
    }
}
Eigen::JacobiSVD<Eigen::MatrixXd> svd(A, Eigen::ComputeFullU | Eigen::ComputeFullV);

Eigen::VectorXd b(points.size());
for (int i=0; i<points.size(); i++)
    b[i]=points[i]->y;
poly_coeff=svd.solve(b);

Is there a similar, or even any way to do L1-norm fitting of polynomial to points using Eigen?
twithaar
Registered Member
Posts
10
Karma
0
You could try iteratively reweighed least squares,
which is a loop around your current code to alternatively least-square fit, and recalculate the weights.

There's no mathemathical guarantee for convergence, however, so you'd have to test it to see
how well it works for your problem.
http://en.wikipedia.org/wiki/Iteratively_reweighted_least_squares#Lp_norm_linear_regression
User avatar dzenanz
Registered Member
Posts
35
Karma
0
OS
I solved it using lpsolve library, see here:
http://stackoverflow.com/questions/1706 ... ng-l1-norm

 
Reply to topic

Bookmarks



Who is online

Registered users: AGB, airdrik, alake, Alexa [Bot], anditosan, Artmessiah, asevens, Baidu [Spider], belnac, Bing [Bot], colomar, Exabot [Bot], garthecho, Google [Bot], google01103, GreatEmerald, kainz.a, koriun, La Ninje, MiceAreVeryNice, mmistretta, nezumi, parzt, Philippe44, scummos, SeaJey, SurfFalke, Tuukka, wolfi323, Yahoo [Bot]