Possible to store 2 dimensional distribution as a univariate distribution? I am dealing with a dataset that has -

*

*many "measurements" (say X, Y and Z)

*a tremendous amount of data (at least considering we need to query it on the fly)

*and a user base that is interested in joint probabilities of measurements (e.g. P(X >= x & Y <= y) | P(Y <= y))

**NOTE**: All measurements of interest are binned

*

*Our univariate distributions are stored as t-digests that are pretty efficient and they are also accurate for our needs

*Currently, we are storing the joint distributions - of say X, and Y - as nested maps in our database where keys of the outer map correspond to bins of X, those of the inner map correspond to bins of Y, and the values of the map correspond to frequency of x-bin, y-bin. while this helps us "build & answer" the joint probabilities queries, nested maps are computationally inefficient

*Consequently, I am exploring to see if its possible to store the bivariate distribution (say of X, and Y) as univariate distribution of say Y projected onto X (for example, I could split the "bin of X" into total bins of Y and then frequency of a given x-y bin could be stored as that of this single projected variable) and then recruit the aggregate structures we use for univariate

Problem

*

*My idea of "projection" isn't quite working out though. The projected variable's quantiles work out very different results compared to the 2-D distribution. I tried to account for two items I noticed -

*

*x-bin, max-y-bin are too close to x-bin + 1, 0 - so I tried to split "x-bin" into total-y-bins * 3 and "interleave" y-bin values

*I also built the distribution using a variable that is 5X the projected variable thinking the t-digest algorithm is perhaps merging these bins



Question
Not withstanding the t-digest approach to aggregating the univariate projection of the bivariate distribution (as that may be introducing issues, at least in part, to how the algorithm works relative to this problem), is it even possible in principle, to capture the distribution of a 2-d variable as a univariate distribution?

You can change your data by flattening the matrix without losing any information. You can convince yourself thereof by noting that you can of course easily re-create the matrix from the flat vector.
And, if you want to, you can also think of the $(n\cdot m)$-dimensional vector (that is the flattened $n\times m$ probability matrix) as a new one-dimensional probability density and apply your T digest to it.
But it will then be more cumbersome to compute those joint probabilities you mentioned above. Extracting those from the T digest of the flattened vector will be difficult and maybe the problems you will get are worse than the benefits.
