Construct a TH2 out of two TH1's

Hi,

I want to construct a 2D histogram out of two 1D histograms with the same bins, is there an efficient way to do that? or is it even possible?

Thanks!

Hi,
in general this is fundamentally impossible, the same way that in general it’s not possible to reconstruct a joint probability distribution p(x,y) given the two marginal distributions p(x) and p(y). The 2D histogram (approximating the joint probability distribution) cannot be reconstructed from the two 1D histograms (approximating the marginal probability distributions).

In a particular, restricted setting, for a specific definition of “constructing a 2D histogram”, you might be able to do something, I’m not sure.

EDIT: also see https://math.stackexchange.com/questions/1255427/joint-distribution-function-from-marginals

Cheers,
Enrico

For instance you can get the binning from the first 1D histogram (all the getters are available for that) to make the x bins of the 2D histogram and the binning of the 2nd 1D histogram to make the y bins … but then you will have an empty nx x ny 2D histogram. if that’s what you what it is fine. There is no way to construct the contain.

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