# How to implement conditional probability distribution on set-valued Random variables

I'm trying to implement conditional probability distribution when the events of two RVs are sets. If I try to extrapolate concepts from real or categorical variables to sets things become confusing for me. In particular, for some pair of discrete RVs, $$X,Y$$ we can compute the conditional probability of two events by using the Bayes theorem: $$P(Y=y|X=x)=\frac{P(X=x|Y=y)P(Y=y)}{\sum_{y'\in\mathcal{Y}}P(X=x|Y=y')P(Y=y')}=\frac{f(x,y)}{\sum_{y'\in\mathcal{Y}}f(x,y')},$$ where $$f(x,y)=\sum_{(x',y')\in (\mathcal{X},\mathcal{Y})}\chi(x'=x,y'=y)$$ is an accumulator function giving the total number of times the specific joint event $$x,y$$ is observed in the sample space (i.e. the indicator function $$\chi(x'=x,y'=y)$$ equals one when $$x'=x,y'=y$$ holds). I'd like to compute such probability when events drawn by $$X,Y$$ are sets $$X_i,Y_j$$, respectively. So, how to define the corresponding $$f(X_i,Y_j)$$?

I've tried with: $$f(X_i,Y_i)=\sum_{j}|(X_i\cap Y_i)\cap(X_j\cap Y_j)|.$$ The motivation behind is that $$X_i\cap Y_i$$ provides a measure of how the attributes of both sets should be observed jointly (such as any intersection event). In turn intersecting this intersection event against other intersection events $$X_j\cap Y_j$$ should provide the measure of how much the joint attributes are observed through the sample space. However, I'm not sure whether this analogy is correct with respect to the usual notion of observing joint events in a sample space. Please, some one can help me to clarify/fix/prove this?

Keeping it to discrete space, the joint probability of an event can be interpreted as the fraction of the size of this subset compared to the whole state space.

In case of events, being sets themselves, the definition remains the same.

$$P(X_i,Y_j) = \frac{|\{(x,y) \in (X_i,Y_j)|\}} {|\Omega|}$$

$$|\Omega|$$ is just the set of all combinations of single events (x,y).

Let us now check your formula with the following example: $$X_0 = Y_1 = \{0\}, ~~ X_1 = Y_0 = \{1\}$$ Then the total space space $$X \times Y$$,

$$\Omega = \{(0,0),(0,1),(1,0),(1,1)\}$$

And for example: $$P(X_0,Y_0) = P( (0,0) ) = \frac{1}{4}$$

Your formula however implies, $$| (X_i \cap Y_i) \cap (X_j \cap Y_j) | = 0$$ as $$X_i \cap Y_i$$ is empty per contruction in the example.

• Thanks for your answer @Benoit Descamps, I'm a bit confused with your example. I understand that $P((0,0))=1/4$ because $(0,0)$ is observed once in the four events defined for $\Omega$, so the equality $P(X_0,Y_0)=P((0,0))$ implies $P(X_0,Y_0)=P(X_0,Y_1)$? – Nacho Nov 22 '20 at 20:53
• Yes for this example it is the case – Benoit Descamps Nov 22 '20 at 21:31
• Thank you Benoit Descamps, your answer helped me a lot. – Nacho Nov 24 '20 at 1:55
• Dear @BenoitDescamps, I'm trying to get an expression for my implementation. It works for you example: $f(X_i, Y_j)=\sum_{X_i'\in\mathcal{X}}\sum_{Y_i'\in\mathcal{Y}}|X_i\cap X_i'|\cdot |Y_i\cap Y_i'|$ . Could you tell me if it should be the general way to do the calculations by making the substitution in the right hand side of first equation of the original question? what do you think – Nacho Nov 30 '20 at 23:44