TH1 quantiles

Dear experts,

I have two TH1 histograms, say h1 and h2, and I want to adjust the shape of h2 to the shape of h1 using the quantiles. This means, that given an xq value from my h2:

h2->GetQuantiles(nq,yq,xq),

I want now to obtain the corresponding xq in the h1 histogram for this quantile value, aka. the “inverse quantile”. However, I found no function for that in TH1. Is there any resource available for this?

Thank you very much in advance,
Jasone

Hi,

I am not sure I have understood your question. The TH1::GetQuantile function returns the histogram x value corresponding to a given probability content (e.g. 25 % of the bin content).

Now what given the quantile x for a given probability p in h1, what do you want from h2 ?
If you want the probability for x in h2, just use h2.Integral(xmin,x)/h2.Integral(xmin,xmax)

Best Regards

Lorenzo

Dear Lorenzo,

Thanks a lot for youre answer. I think I might have misunderstood the getQuantile function. Actually what I need is: given the value of the integral between 0 and the x2 in h2 (which I was calculating using h2->getQuantiles), find the corresponding x1 value to this integral value in h1. Or in other words, find the value x1 from h1 for which the integral value is the same as for x2 in h2.

From your answer I understand I was not using the correct funtion?

Hi,

The quantiles see en.wikipedia.org/wiki/Quantile
are the inverse of the CDF. So they give exactly what you want, given an integral value (the probability) they return the corresponding x.
To compute the integral use TH1::Integral(min, xmax). Remember that you need to pass probabilities to the quantiles, so you need to re-normalize (divide) the computed integral by the total integral of the histogram.

Lorenzo