Suppose we have the following probabilistic graphical model:

$L \rightarrow X, L \rightarrow Y, F \rightarrow Y, X \rightarrow D, Y \rightarrow D$.

That is, the joint is: $P(D,X,Y,L,F) = P(D|X,Y)P(X|L)P(Y|L,F)P(L)P(F)$.

Here $L,F,D$ are discrete, $X,Y$ are continuous random variables (having proper pdf's).

I want to compute $P(D=d,L=l | X=x, F=f)$. Note that we have already observed ($x$) for one of the continuous variables.

Here is my solution attempt so far:

$P(d,l | x, f) = \frac{P(d,l,x, f)}{P(x,f)}$ Let's ignore the denominator for now. The numerator:

$P(d,l,x,f) = \int_y P(d|x,y) P(x|l) P(y|l,f)P(l)P(f)$

Now, $P(x|l)$ and $P(y|l,f)$ should be zero because they are continuous variables. But we have already observed the value of X. So, I am not sure how to proceed from now on. My guess is that we should use the pdf's instead of probabilities:

$P(d,l,x,f) = \int_y P(d|x,y)\;f_{X|L}(x|l)\;f_{Y|L,F}(y|l,f)\;P(l)\;P(f)dy$

Is this correct?

If this is correct, then another question is how to compute this integral. Would the following work?

Sample a $y$ from $f_{Y|L,F}(Y|l,f)$, compute $P(d|x,y)$ and then compute $g(y) = P(d|x,y)\;f_{X|L}(x|l)\;P(l)\;P(f)$. Do this a large number of times and take the average of $g(y)$'s. ???

Any ideas, hints, directions would be highly appreciated.


1 Answer 1


Your derivation looks correct and is consistent with how joint distributions that are a mix of discrete and continuous are normally handled.

Note that some of the things inside your integral do not depend on $y$. You can re-write it as

$$ P(d,l,x,f) = P(l) P(f) f_{X|L}(x|l) \int_y P(d|x,y) f_{Y|L,F}(y|l,f) dy $$

This is an integral against the conditional density of $Y|L,F$, which you can estimate using the procedure you described, which is known as Monte Carlo Integration. The basic idea is that if you want to estimate an integral against a density, $p(x)$:

$$ I = \int g(x) p(x) dx $$

then this can be written as the expected value of the random variable $g(X)$, where $X$ has distribution $p$. Therefore, if you

(1) Simulate values of $X \sim p$ and

(2) Calculate $\hat{I}$, the sample mean of $g(X)$

then $\hat{I}$ is a consistent estimator of $I$, by the Law of Large Numbers. In finite samples, the standard deviation of this approximation will be $\sqrt{{\rm var}( g(X) )/n}$, so you can see the larger the sample size you use, the more accurate your estimates will be, both in terms of the potential bias (i.e. the consistency of the estimator) and the precision (the reduction in variance).

In your case, note that the integral in your problem can be written as an expectation against the joint density of $Y|L,F$:

$$ P(d,l,x,f) = P(l) P(f) f_{X|L}(x|l) \cdot E_{Y|L,F} \left( P(d|x,Y) \right) $$

Therefore, if you can generate from the conditional distribution of $Y|L,F$, then the method you described is feasible for estimating $E_{Y|L,F} \left( P(d,x,Y) \right)$; all other terms are constants in $y$, and so they can be pulled out the integral. Above I've described the simplest possible form of monte carlo integration and if simulating from this distribution has high computational cost, you may consider a more sophisticated method (like importance sampling) that will require less simulation for a fixed level of monte carlo error you're willing to accept in your estimate.

Edit: Another method for calculating the integral is numerical integration, which only requires you to be able to calculate the integrand. Numerical integration is typically difficult itself when the objective function is complicated and is not as intuitive as monte carlo integration, so you probably don't need to consider it unless the distribution of $Y|L,F$ is impossible to sample from or is computationally expensive to the point that you couldn't take enough samples to get a precise estimate of the integral.

  • $\begingroup$ What about $f(x|l)$? This is actually the likelihood of $x$ as a function of $l$, and its absolute value is immaterial. How to deal with this? I'm thinking of using likelihood ratios where the likelihood function in the denominator is kept the same for all values of $l$. Does it make sense? $\endgroup$
    – emrea
    Commented May 28, 2012 at 21:35
  • $\begingroup$ I accidentally left that term out of the final equation - thanks for catching that (fixed). In terms of the integral, $f_{X|L}(x|l)$ is a constant, so you can just factor it out and multiply at the end. $\endgroup$
    – Macro
    Commented May 28, 2012 at 21:37
  • $\begingroup$ I will compute this probability for different values of $L$ so the value of $f(x|l)$ matters. $\endgroup$
    – emrea
    Commented May 28, 2012 at 21:38
  • $\begingroup$ Once you have the value of $E_{Y|L,F} \left( P(d|x,Y) \right)$, which you can calculate by monte carlo integration, calculating the joint probability is no more difficult than evaluating the constant terms out in front $\endgroup$
    – Macro
    Commented May 28, 2012 at 21:40
  • 2
    $\begingroup$ this question also has an open bounty ending in 3 days at mathoverflow $\endgroup$ Commented Jun 1, 2012 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.