# Calculating joint probabilities from conditional probabilities, categorical variables

I want to calculate the joint probabilities P(X,Y), where X and Y are both categorical variables with 7 and 6 categories each. Given the conditional probabilities P(X|Y), is it possible to calculate the joint probabilities P(X,Y)?

If it is not possible from just P(X|Y), would it be possible if I had both P(X|Y) and P(Y|X)? As I have a model for estimating the conditional probabilities, but not the joint probabilities. And how would this exactly be done? I learnt how to do this in the case that both X and Y are binary variables, from this question,

Calculating joint probability and covariance given conditional probabilities

but I am not quite sure how to extend this to the multinomial variables case. Thank you so much!!

• I think you could extend that same problem with more categories. The second answer shows the method. – dankernler May 10 '18 at 11:56

If you have both conditional probabilities, you can find the joint using Brook's lemma. In your case you have $$P(X=x,Y=y) = P(X=x_0,Y=y_0)\frac{P(X=x|Y=y_0)}{P(X=x_0|Y=y_0)}\frac{P(Y=y|X=x)}{P(Y=y_0|X=x)}$$ where $(x,y)$ are the points where you want to evaluate the probabilities, and $(x_0,y_0)$ is a set of possible values. Then, computing $P(X=x,Y=y)$ for all possible values and remembering that their sum must be 1, you can find the joint density.