Merge adjacent bins until specific threshold is reached

Hello,

I have a 2D histogram (Response Matrix). It has equidistant binning. the x-axis is the reconstructed level, and the y-axis is the generator level.
Now I want to create a custom binning from the histogram.

Requisite:

Starting at the smallest values of a histogram, the neighboring bin (both on reco and gen axes) is merged into the current bin until both the purity and stability of the current bin exceed a threshold of 50%. The purity is defined as the fraction of entries in that (reco, gen) bin relative to all entries in that reco bin, while the stability is defined as the fraction of entries in that (reco, gen) bin relative to all entries in that gen bin. Once this threshold has been met, a new bin is started, and the bin-collating procedure is repeated until the end of the axis has been reached. And finally, print the final bin-edges of the merged histogram.

Could anyone suggest or give a script for doing this bin-collating procedure?

Thanks,
Soumyadip

Rebinning a 2D histogram into variable bins is not supported.

Well, I hope this will work … “scan” your original 2D histogram and create a table of the new bin edges, then create a new (empty) 2D histogram with these new edges, and finally “add” the original 2D histogram to the new one.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.