Home | News | Documentation | Download

Fitting a sum of Legendre polynomials

Dear experts,

I have a distribution in data between x-values of -1 and 1 that should follow a sum of Legendre polynomials, and I want to extract the fraction of order 0, order 1 etc, up to some fixed order, e.g. order 4.

For this, I tried to fit a RooGenericPdf since the RooLegendre class is not implemented as Pdf, however, this does not converge at all. I tried to fit the data with a RooChebychev, and this works perfectly fine. I could now calculate the coefficients of the Legendre Polynomials from these Chebychev coefficients, but it feels like there must be a better way to do this.

Do you have any suggestions?

Thanks a lot in advance!
Sophie

Hi @skratch,

the problem with the Legendres is that they can be negative. Therefore, they cannot be PDFs. The same problem will bite you if you try to implement them yourself. Once you go negative, it’s end of fit.

One thing that can work, though, is to use a RooRealSumPdf with an offset. That’s a PDF that consists of components which themselves are allowed to be negative, only their sum has to be positive.
If you e.g. sum a Legendre and a constant offset, you can get the whole thing to be positive. Add the same offset to the data, and the fit can proceed.

Thanks very much for the fast and helpful response - it works now!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.