# Assuming n variables are conditionally independent given y, how do I compute p(y | x_1,…,x_n)?

Referencing this question, I know that if $x_1$ and $x_2$ are conditionally independent given $y$ (big assumption), then

$$P(y | x_1,x_2) = \frac{P(x_1,x_2 | y)P(y)}{P(x_2 | x_1)P(x_1)}$$ $$= \frac{P(x_1| y)P(x_2| y)P(y)}{P(x_2 | x_1)P(x_1)}$$ $$= \frac{P(y| x_1)P(x_2| y)}{P(x_2 | x_1)}$$

How do I generalize to $n$ variables and compute $P(y | x_1,...,x_n)$? I don't know any of the priors, but I have all the single conditional probabilities (complete matrix)!

Summary

1. Known: $P(y|x_i), P(x_i|y)$, and $P(x_i|x_j), \forall i,j$
2. Assumption: $x_1,...,x_n$ are conditionally independent given $y$
3. Problem: Compute $P(y|x_1,...,x_n)$.

Any help would be appreciated!

UPDATE (reply to Xian):

So to further clarify my problem: I have a disease set $D=\{d_1,...,d_m\}$ and a symptom set $S=\{s_1,...,s_n\}$.

For a given disease, $d_i$, I know the probabilities of the symptoms, $p(s_1| d_i),...,p(s_n|d_i)$ (sparse). For a given symptom $s_j$, I have probabilities $p(d_1 | s_j),...,p(d_m | s_j)$ (also, sparse).

Now, I want to compute $p(d_i | s_{\alpha_1},...,s_{\alpha_k}), \forall i\in[1:m]$, for $k\leq n$ (probability of each disease given a subset of symptoms).

If I understand your answer correctly, you're saying that for a given disease $d$, I can sample a synthetic patient with some symptoms based on the distribution of conditionals $p(s_j | d), \forall j$. But how would I incorporate $p(y|x_1)=p(d_i|s_1),\forall i$ into the sampling procedure so that I can account for the fact that, say, the common cold occurs more frequently than tuberculosis given cold-like symptoms?

Sorry for the confusion!

• It seems to me that you need the full set of conditional probabilities $p(x_i | x_{-i})$, not just the pairwise conditional probabilities. – jbowman Jun 14 '18 at 22:43

Since the $X_i$'s are independent given $Y$, the joint density of $(Y,X_1,\ldots,X_n)$ writes down as$$p(y)p(x_1|y)\cdots p(x_n|y)$$and hence the conditional of $Y$ given $(X_1,\ldots,X_n)$ is $$\dfrac{p(y)p(x_1|y)\cdots p(x_n|y)}{\int p(y)p(x_1|y)\cdots p(x_n|y)\text{d}y}$$It simplifies into $$\dfrac{p(x_1)p(y|x_1)p(x_2|y)\cdots p(x_n|y)}{\int p(x_1)p(y|x_1)p(x_2|y)\cdots p(x_n|y)\text{d}y}=\dfrac{p(y|x_1)p(x_2|y)\cdots p(x_n|y)}{\int p(y|x_1)p(x_2|y)\cdots p(x_n|y)\text{d}y}$$but I see no further simplification.
• Thanks for the response @Xi'an. I don't actually have access to a dataset for this problem; however, I have the numerical values for the elements of the joint density $p(y|x_1),p(x_2|y),\cdots, p(x_n|y)$. To numerically evaluate the integral in the denominator, would I just compute the joint density in the numerator for each possible value of $y$ and sum? Wouldn't I still be ignoring the prior in $dy$? – D. Rad Jun 23 '18 at 17:20
• If you can evaluate the numerator, you can simulate from this distribution without knowing the value of the normalising integral in the denominator. This formula is correct for the conditional in $y$ : hence no you do not ignore the prior. – Xi'an Jun 24 '18 at 5:43
• If $Y$ has a discrete support, the integral in the denominator becomes a summation over all possible values $y$. – Xi'an Jun 27 '18 at 5:42