# Inference on a probabilistic graphical model with observed continuous variable

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.

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.

• 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? – emrea May 28 '12 at 21:35
• 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. – Macro May 28 '12 at 21:37
• I will compute this probability for different values of $L$ so the value of $f(x|l)$ matters. – emrea May 28 '12 at 21:38
• 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 – Macro May 28 '12 at 21:40
• this question also has an open bounty ending in 3 days at mathoverflow – David LeBauer Jun 1 '12 at 5:03
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9828990697860718, "perplexity": 157.83461187650045}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-05/segments/1579250615407.46/warc/CC-MAIN-20200124040939-20200124065939-00245.warc.gz"}