Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour of KSTest with toys ("X" option) for identical histograms #13697

Closed
1 task done
TomasDado opened this issue Sep 21, 2023 · 2 comments
Closed
1 task done

Comments

@TomasDado
Copy link

Check duplicate issues.

  • Checked for duplicates

Description

When passing some identical histograms to KSTest of TH1, the code return probability 0 in case of the "X" option (runing toys) while the probablity of the default KS test is 1 (as expected).

Reproducer

running the following macro reproduces the issue:

void kstest() {

  TFile* f = TFile::Open("kstest.root", "READ");

  TH1D* h1 = f->Get<TH1D>("SR2_2L_el/tt_Conv/nominal/SR2_2L_el_tt_Conv");
  TH1D* h2 = f->Get<TH1D>("SR2_2L_el/tt_Conv/FSRAlphaS_ttbar/SR2_2L_el_tt_Conv_FSRAlphaS_ttbar_Shape_Down");

  std::cout << "integral h1: " << h1->Integral() << ", h2: " << h2->Integral() << "\n";

  const double probX = h1->KolmogorovTest(h2, "X");
  const double prob  = h1->KolmogorovTest(h2);
  std::cout << "KS probability using toys is: " << probX << ", without toys it is: " << prob << "\n";
}

with the input file available in this public afs repository: /afs/cern.ch/user/t/tdado/public/kstest.root

I could not reproduce it with a dummy histograms, so it must be somehow related to the actual values in the bins?

ROOT version

ROOT Version: 6.28/04
Built for linuxx8664gcc on Jul 10 2023, 18:22:00
From v6-28-04@v6-28-04

Installation method

source from LCG

Operating system

CentOS7 (lxplus)

Additional context

No response

@lmoneta
Copy link
Member

lmoneta commented Oct 6, 2023

The problem is that one of the histogram is having all bin errors equal to zero. Is this intentional ?
If not please add the correct errors and the test will work correctly.
In that case the toy option (X) does not work and it returns a zero probability. An error should be probably produced, but this could be probably supported. I can provide a fix for this.
Thank you for the report

lmoneta added a commit to lmoneta/root that referenced this issue Oct 6, 2023
…ro errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue root-project#13697
lmoneta added a commit to lmoneta/root that referenced this issue Oct 6, 2023
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue root-project#13697
@TomasDado
Copy link
Author

Hi, thanks for the reply, indeed, in this case the histograms do have 0 uncertainties. I was just surprised by the 0 probability. I think an error message would help, thanks!

lmoneta added a commit to lmoneta/root that referenced this issue Jan 16, 2024
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue root-project#13697
lmoneta added a commit that referenced this issue Jan 17, 2024
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue #13697
@lmoneta lmoneta added this to Issues in Fixed in 6.32.00 via automation Jan 17, 2024
@lmoneta lmoneta closed this as completed Jan 17, 2024
@guitargeek guitargeek added this to Issues in Fixed in 6.30.04 via automation Jan 22, 2024
guitargeek pushed a commit to guitargeek/root that referenced this issue Jan 22, 2024
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue root-project#13697
guitargeek pushed a commit that referenced this issue Jan 23, 2024
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue #13697
vgvassilev pushed a commit to vgvassilev/root that referenced this issue Feb 8, 2024
…ero errors

Fix the case of using KS test when one of the histogram has zero errors (i.e is a function).
Improve KS test adding possibility to specify number of toys by using option
"X=number" for example "X=1000"

This fixes the issue root-project#13697
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

2 participants