Skip to content

Chi2Test: Report residuals also for higher dimensions #20761

@phi-mah

Description

@phi-mah

I wanted to perform a chi^2 comparison between two TH2 histograms (h1 and h2), making use of the TH1::Chi2Test method. I hoped to get access to the individual residuals as follows:

TH2D h_res {*h1};
h_res.Reset();

h1->Chi2Test(h2, "OF UF" , h_res.GetArray());

//h_res should now contain the residuals

It really took me some time to understand why this is not working. It turns out this is a bug(?) in the code. The expression that fills the residuals only considers one dimension (x, lookp variable i) and simply ignores y (j) and z (k):

if (res) res[i - i_start] = (cnt1 - nexp1) / TMath::Sqrt(nexp1);

I understand that a higher dimensional res array layout is more complicated, especially if custom limits are involved. Nevertheless I would expect at least the full 2D/3D case (as sketched above) to work.

Metadata

Metadata

Type

No type

Projects

Status

No status

Status

No status

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions