Linear Fit

Could anybody explain me how to fit a scatter plot (TH2) for a linear regression?

Thanks a lot in advance

Raffaello Trentadue

Does somebody have an answer for that ?
And I don’t want to use ProfileX or FitSliceX, because it doesn’t give me the answer I want if I don’t rotate my histogram. I tried a simple fit with a TF1 but I didn’t get a reasonable answer.
In fact what I want is just a linear regression of a scatter plot (!).
Sorry for spamming.


Fitting a TH2 histogram with 1D-function should work and I guess is what you want.
Maybe the presence of large residuals sopoil your fit result. In that case you could try also to convert the TH2 in a TGraph and fit it using the linear robust fitting

Cheers, Lorenzo

I have discovered a bug when fitting the scatter plot with 1D function. It should be fixed now in the ROOT trunk, after revision 38139


Thanks Lorenzo.
I was afraid to post about this, but if there is a bug I guess I wasn’t spamming.