Generate conditional probability matrix for simulation I want to generate a categorical random variable conditioned on other variables, for example, generate $X$ from $Y$ by $P(X|Y)$, or generate $X$ from $Y_1,Y_2$ by $P(X|Y_1,Y_2)$.
Here, $P(X|Y)$ represents a conditional probability matrix, where value of the $i$-th row and $j$-th column $[P(X|Y)]_{ij}$ is the conditional probability $Pr(X=x_i|Y=y_i)$.
My questions are:

*

*Having know the levels of $X$ and $Y$, how to simulate many different conditional probability matrices $P(X|Y)$?

*Can we manage to control the correlation between $X$ and $Y$ (strong or rather weak) when simulating these conditional probability matrices?

*Extending the above questions to scenarios with more than one conditioned variables, say, simulating a matrix $P(X|Y_1,Y_2,...,Y_n)$, can we manage to control the correlation between $X$ and $Y_1,Y_2,...,Y_n$, respectively?


I presume that you wanted your definition to be:
$$
[P(X|Y)]_{ij} = Pr(X=x_i| Y = y_j).
$$
Your first question:
You can simulate such matrices by just randomly assigning nonnegative values to the matrix cells such that the columns sum to one.
Your second question:
If the columns are all the same, i.e. $Pr(x_i|y_j)$ is independent of $j$, then $Pr(x_i|y_j)=Pr(x_i)$, which is the definition of independence, so the more the columns differ, the more you deviate from independence.
Your third question:
Just consider $\mathbf Y = (Y_1,\ldots, Y_n)$ as a single random variable with its values being all possible combinations of levels of the $Y_i$, and you have the same task as above.
