Fit Chebyshev

Hi all,

I’m looking for a simple example on how to fit a histogram with Chebyshev polynomials. From the documentation of ROOT::Math I couldn’t find a proper interface to use the polynomials inside a TF1 object.

Many thanks,
Oliver

Hi,

The ROOT::Math::Chebyshev class of MathMore performs a polynomial approximation given a function. You want to perform a fit of Chebyshev polynomials to some data (an histogram).
For doing this needs to be modified, I could probably do it for the next release. However, writing a Chebyshev function which can be used for fitting is not so difficult. I attach here an example macro on how to build a TF1 class based on Chebyshev polynomials.
I remind you that exists also a class in RooFit, RooChebychev, which can be used for fitting within the RooFit framework

Best Regards

Lorenzo
exampleFitChebyshev.C (1.16 KB)

This will do. Many thanks!

Hi,

I was checking the code you posted and the fitting function, F(x) (sum of the products of chebyshev polynomials with the fitting coefficients) defined between, lets say, “a” and “b” is evaluated at (x - a - b)/(a+b), instead of at x. I am not sure why you defined the polynomials in that way.

Maybe you want to define F(x) with x belonging to [-1,1] rather than [a,b], given that the polynomials are orthogonal in that interval ? In that case it should be (2x-a-b)/(b-a).

Thanks

Hi,
You are right. There is a bug in that example. I have uploaded now a fixed version of the macro.
Also, we have in ROOT in 5.34 a new class ROOT::Math::ChebyshevPol that defines the Chebyshev polynomial and can be used to build a TF1. There is no possibility now to rescale this class for the range, but I will implement this for the next version.

root.cern.ch/root/html/ROOT__Mat … evPol.html

Thank you for reporting this error
Best Regards

Lorenzo
exampleFitChebyshev.C (1.16 KB)