TLinearFittter and NormalEq: What am I doing wrong?

Hello all.

The output of the attached modification of solveLinear.C is:


$ root solveLinear.C
ROOT 5.19/02 (trunk@22600, May 12 2008, 20:41:00 on linuxx8664gcc)

CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008

    1. Normal Equations par[1] 0.635849 par[2] 1.06618
    1. SVD par[1] 0.635849 par[2] 1.06618
    1. TLinearFitter par[1] 2.85556 par[2] -0.677778


I would expect (3) to give exactly the same results as (1.) and (2.) (which are correct).
Obviously I did not set up correctly the TLinearFitter ctor.
What is the problem?

Many thanks,
solveLinear.C (1.42 KB)

Hi Dimitris,

In the line, where you assign the data, the second parameter to TLinearFitter::AssignData() has to be 1, not 2, as it’s the number of columns of the X matrix (which in your case is the vector ax).

In other words, it’s the number of dimensions in the fitting formula, not the number of linear terms in it. Maybe I should clarify this in the documentation.

Hope it helps

Case closed!

Thanks Anna.