root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.64k stars 1.26k forks source link

TH1::GetQuantiles provide wrong results for some usecases #9364

Closed linev closed 2 years ago

linev commented 2 years ago

Example:

 auto h1 = new TH1I("h1","h1", 100, -10, 10);
   h1->Fill(-5);
   h1->Fill(5);
   h1->Draw();

   Double_t quantiles[3], prob[3] = { 0.25, 0.5, 0.75 };
   h1->GetQuantiles(3, quantiles, prob);

   for (int n=0;n<3;n++)
      printf("prob %5.2f quantile %6.3f\n", prob[n], quantiles[n]);

Output is:

prob  0.25 quantile -4.900
prob  0.50 quantile  4.800
prob  0.75 quantile  5.100

I would expect that for probability 0.5 quantile is near 0.0. Function used in candle plot and because of this feature produces confusing output.

lmoneta commented 2 years ago

This problem has been already reported in https://sft.its.cern.ch/jira/browse/ROOT-8085

We need to have a new implementation of TH1::GetQuantiles, extending what is available in TMath::Quantiles for weighted data set.

linev commented 2 years ago

Yes, it is same problem. Actually, solution is very simple and I implement it with JSROOT. One can copy it to the C++

linev commented 2 years ago

Duplicates JIRA issue, close here

github-actions[bot] commented 2 years ago

Hi @linev, @lmoneta,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot: