# Calculate probability using brute-force method

I have to calculate a probability using the following probabilities from a Bayesian network: $$P(+a)=...$$ $$P(+a|+b)=..., P(+a|¬b)=...$$ $$P(+b|+a)=..., P(+b|¬a)=...$$ $$P(+d|+b)=..., P(+d|¬b)=...$$ $$P(+f|+b,+c)=..., P(+f|¬b,+c)=..., P(+f|¬b,¬c)=...$$ $$P(+g|+c)=..., P(+g|¬c)=...$$

I have to calculate $$P(a|+d,+f,¬g)$$.

I have no idea about how to do it, but I guess it is something like that:

$$P(a|+d,+f,¬g)=\frac{P(a,+d,+f,¬g)}{P(+d,+f,¬g)}$$

And then, I have to calculate $$P(a,+d,+f,¬g)$$ and $$P(+d,+f,¬g)$$ using the previous probabilities. Is that correct?

But the $$P(a|$$ is confusing me because it hasn't a + or a ¬.

NOTE: you don't have to elaborate each formula, only point me to the right direction.

• Please, do not downvote. I can read. Your comment is enough to make me remove the image. Thanks. – VansFannel Apr 30 '19 at 15:17
• Downvote converted to upvote. Please note that downvote indicates my personal dislike for text images, since this is inconsiderate for those using screen readers and other assistive technologies, notably those with Disorders of Reading and Writing, visually impaired, etc. Besides, it's not searching on search engines like Approach0 – GNUSupporter 8964民主女神 地下教會 Apr 30 '19 at 15:28

## 1 Answer

The Bayesian network tells you that the joint distribution factorizes according to $$P(a,b,c,d,f,g) = P(a)P(b|a)P(c|a) P(d|b)P(f|b,c) P(g|c),$$ So you can compute any truth assignments using the conditional distributions you have presented.

For instance $$P(+a, \neg b, +c, \neg d, +f, +g) = P(+a)P(\neg b|+ a)P(+ c| + a) P(\neg d| \neg b)P(+ f|\neg b,+c) P(+g|+ c).$$ Note that you have all these probabilities: for those that you do not have explicit, consider the normalization constraint that tells you that $$P(\neg E) = 1 - P(E)$$.

You have correctly written that $$P(a| +d, +f, \neg g) = \frac{P(a,+d,+f,\neg g)}{P(+d,+f,\neg g)}.$$ Note that this is a short-hand that represents two probabilities: $$P(+a|+d,+f,\neg g)$$ and $$P(\neg a|+d,+f,\neg g)$$. By normalization, you only need to compute one of them, and the other one follows by $$P(+a|+d,+f,\neg g) = 1 - P(\neg a|+d,+f,\neg g)$$; so we only look at $$P(+a| +d, +f, \neg g)$$.

Now we need observe that the numerator and denominator probability involve a subset of the variables. This means that we must marginalize. We need to remove the variables that do not appear using the sum-rule of probability theory:

$$P(A) = \sum_B P(A, B).$$

In your case, we have that $$P(+a, +d, +f, \neg g) = \sum_{b,c} P(+a, b, c +d, +f, \neg g),$$ where the summation sign means that we sum over all possible outcomes of $$b$$, and $$c$$: $$P(+a, +d, +f, \neg g) = P(+a, +b, +c +d, +f, \neg g) + P(+a, +b, \neg c +d, +f, \neg g) + P(+a, \neg b, +c +d, +f, \neg g) + P(+a, \neg b, \neg c +d, +f, \neg g).$$ To compute each one of these probabilities, you use the definition of the joint at the beginning of the answer.

Similarly, you can compute $$P(\neg a, +d, +f, \neg g)$$. Then, you use the same rule to compute $$P(+d, +f, \neg g) = P(+a, +d, +f, \neg g) + P(\neg a, +d, +f, \neg g).$$

It's a lot of products and sums :) good luck!

• Thanks for your answer. I don't understand this sentence "We need to remove the variables that do not appear using the sum-rule of probability theory". I think you are saying that to get the probability of A, I have to sum all the probabilities where A appears. – VansFannel Apr 30 '19 at 15:13
• Quite the opposite, if you want the probability of $A$, but only know the joint $P(A,B)$, then you need to "remove" the $B$ from the joint, to find $P(A)$. You do this by summing the joint over all the possible outcomes of $B$: for instance $P(A) = P(A,+B) + P(A,\neg B)$. – Riccardo Sven Risuleo Apr 30 '19 at 15:15
• Maybe I misunderstood your point: a lot of terms in the summation may disappear; the only ones that matter are the ones where the variable you are interested in appears (together with all the ones they are conditioned upon). – Riccardo Sven Risuleo Apr 30 '19 at 15:19
• Thanks. In case of $P(+d, +f, \neg g)$, why don't you use $b$ and $c$? In other words, why do you use only $a$ to calculate it? Thanks. – VansFannel Apr 30 '19 at 15:26
• I think you have forgotten the $c$ on the first formula. – VansFannel Apr 30 '19 at 15:49