0
$\begingroup$

Consider a simple Bayesian Network of three variables A, B, and C. All of the variables are discrete variables between (0,1] that are discretized as below:

Ψ (A,B,C) : {(0,0.2], (0.2–4], (0.4–0.6], (0.6–0.8],(0.8–1]}

I Know A and B are discretized Truncated Normal distributions with a mean of 0.4, and variance of 0.1; such as:

A, B ~ TNormal{(0,1],0.4,0.1}

And I know that C is a deterministic function of the two distributions e.g. is an average of the two, with the same variance.

C ~ TNormal{(0,1],(A+B)/2,0.1}

How can I calculate the CPT for node C, from A, and B, that creates the same relation? I know some commercial software create those. But I do not know how, and I want to incorporate that in my BNlearn graph so that it can work as part of the back propagation of evidence.

enter image description here

$\endgroup$
10
  • $\begingroup$ What do you mean by your first formula with $\Psi$? $\endgroup$
    – Tim
    Commented Oct 14, 2019 at 16:47
  • $\begingroup$ That they are discretized as such, in 0.2 intervals. $\endgroup$ Commented Oct 14, 2019 at 16:48
  • $\begingroup$ If they are discretized, then they cannot follow truncated normal distributions, because they are continuous distributions. So the statement is contradictory. $\endgroup$
    – Tim
    Commented Oct 14, 2019 at 16:51
  • $\begingroup$ Well, you can discretize the truncated normal distribution as well for the intervals. This only helps to come up with CPTs to use general BN algorithms. $\endgroup$ Commented Oct 14, 2019 at 16:54
  • $\begingroup$ You don't need to discretize anything. Do you have any data, because your don't mention any? $\endgroup$
    – Tim
    Commented Oct 14, 2019 at 17:04

1 Answer 1

1
$\begingroup$

You have three random variables

$$\begin{align} A &\sim \mathcal{TN}_{(0, 1)}(0.4, 0.1) \\ B &\sim \mathcal{TN}_{(0, 1)}(0.4, 0.1) \\ C &\sim \mathcal{TN}_{(0, 1)}(\tfrac{A+B}{2}, 0.1) \\ \end{align}$$

Given your diagram, you seem to assume independence between $A$ and $B$, so the distribution of $C$ is

$$ f(c|a,b) = \mathcal{TN}_{(0, 1)}(c \mid \tfrac{a+b}{2}, 0.1) \cdot \mathcal{TN}_{(0, 1)}(a \mid 0.4, 0.1) \cdot \mathcal{TN}_{(0, 1)}(b \mid 0.4, 0.1) $$

where to calculate cumulative probabilities, you just need to calculate integrals, e.g.

$$ \Pr(C<c) = \int_{-\infty}^\infty \int_{-\infty}^\infty \int_{-\infty}^c f(c|a,b) \;da\,db\,dc $$

To calculate it, you need an algorithm for automatic integration, they are commonly implemented in many software packages. You can use grid approximation as well, but with just five points, as you proposed, you would loose so much information, that it would be a very rough approximation. On another hand, with more detailed grid, this would become more computationally intensive then simple Monte Carlo simulation.

In fact, Monte Carlo sampling is the simplest and most flexible approach. To calculate the quantities of interest, you would draw a lot of samples from the distributions $A$ and $B$, and conditionally on them, from $C$, and then use the estimated statistics from the Monte Carlo samples.

library(extraDistr)
set.seed(42)
n <- 1000000

A <- rtnorm(n, 0.4, 0.1, 0, 1)
B <- rtnorm(n, 0.4, 0.1, 0, 1)
C <- rtnorm(n, (A+B)/2, 0.1, 0, 1)

Given such samples, you can easily calculate the statistics of interest, e.g. $E[C\mid A<0.3, B<0.2]$ would be

mean(C[A < 0.3 & B < 0.2])
## 0.209704025516417

and $\Pr(C<0.3\mid A <0.1, B < 0.2)$ would be

mean(C[A < 0.1 & B < 0.2] < 0.3)
## 0.967741935483871

or $\Pr(C < 0.4)$

mean(C < 0.4)
## 0.499649

etc.

$\endgroup$
5
  • $\begingroup$ Thanks a lot @Tim for your answer. This seems to solve the problem on a much better basis. $\endgroup$ Commented Oct 15, 2019 at 0:12
  • $\begingroup$ I got a question @Tim, what if I want the following quantity Pr( 0.4<C<0.6 ∣ 0.2<A<0.4, 0.6<B<0.8), the mean seems not working. $\endgroup$ Commented Oct 15, 2019 at 2:43
  • $\begingroup$ @PitPartizan what exactly is not working? $\endgroup$
    – Tim
    Commented Oct 15, 2019 at 4:58
  • $\begingroup$ I think the mean command is only calculating the mean for the one tailed cumulative probability, but regardless, could you review the R syntax for Pr( 0.4<C<0.6 ∣ 0.2<A<0.4, 0.6<B<0.8) with me here? how do you get that in R. thanks a lot @Tim ! $\endgroup$ Commented Oct 15, 2019 at 5:10
  • $\begingroup$ @PitPartizan mean(0.4 < C & C < 0.6) etc $\endgroup$
    – Tim
    Commented Oct 15, 2019 at 6:00

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.