Skip to content
PostBayesian Network / Assignment

Bayesian-As-2

2025-11-06
Back to Blog

BN-Assignment-2

Consider the following Bayesian networks with the following nodes

  • R (Rain): it is raining or not, with binary values r: it is raining and rc: it is not raining. val(R)={r,rc}
  • L (Leaves): there are juicy leaves or not, val(L)={l,lc}
  • Q (Quokkas Happiness): the quokkas are happy or unhappy, val(Q)={q,qc}
  • T (Tourists): there are lots of tourists or not many, val(T)={t,tc}
  • S (Selfie Quokka): people are taking lots of quokka selfies, or not, val(S)={s,sc}
zDQc9h

Question 1.

Write the chain rule for the joint distribution P(R,L,Q,T,S) Note: You must use VE (variable elimination) method to solve these questions below!

P(R,L,Q,T,S)=P(R)P(L|R)P(Q|R,L)P(T|R,L,Q)P(S|R,L,Q,T)P(R,L,Q,T,S)=P(R)P(L|R)P(Q|L)P(T|R,Q)P(S|Q,T)

Question 2.

What is the probability that there are many tourists?
Given joint distribution:

P(R,L,Q,T,S)=ϕR(R)ϕL(L,R)ϕQ(Q,L)ϕT(T,R,Q)ϕS(S,Q,T)

We want:

P(T) or specifically P(T=t)

using Variable Elimination (VE).

We will keep T (the query variable) and eliminate the others in the order:

ρ={S,L,R,Q}
  • Find all factors containing S: ϕS(S,Q,T)
  • Eliminate S
    • Only factor with S: ϕS(SQ,T).
τ1(Q,T)=SϕS(SQ,T)=1(constant, drop it)
  • Remaining: {ϕR(R),ϕL(LR),ϕQ(QL),ϕT(TQ,R)}.

  • Eliminate L

    • Multiply the factors with L and sum out L:
g2(L,R,Q)=ϕL(LR)ϕQ(QL),τ2(R,Q)=Lg2(L,R,Q).τ2(R=r,Q=q)=0.80.9+0.20.7=0.86,τ2(R=rc,Q=q)=0.30.9+0.70.7=0.76,τ2(R=r,Q=qc)=0.80.1+0.20.3=0.14,τ2(R=rc,Q=qc)=0.30.1+0.70.3=0.24.
  • Eliminate R
    • Combine factors with R and sum out R:
g3(R,Q,T)=ϕR(R)τ2(R,Q)ϕT(TQ,R),τ3(Q,T)=Rg3(R,Q,T).
  • With P(R=r)=0.2, P(R=rc)=0.8:
τ3(Q=q,t)=0.20.860.7+0.80.760.9=0.1204+0.5472=0.6676,τ3(Q=qc,t)=0.20.140.2+0.80.240.3=0.0056+0.0576=0.0632.
  • Eliminate Q
τ4(T)=Qτ3(Q,T),P(T=t)=τ4(t)=0.6676+0.0632=0.7308.

Question 3.

What is the probability that the quokkas are happy, given there are lots of quokka selfies being taken and it is raining.

P(Q=q|S=s,R=r)P(Q=qS=s,R=r)
  • Factorization & evidence
P(R,L,Q,T,S)=ϕR(R)ϕL(LR)ϕQ(QL)ϕT(TQ,R)ϕS(SQ,T)
  • Evidence: R=r, S=s. Substitute to get factors
{ϕL(Lr), ϕQ(QL), ϕT(TQ,r), ϕS(sQ,T)}

(ϕR(r) is a constant and cancels at normalization).

  • Eliminate variables ρ={L, T} (keep Q).

  • Eliminate L

τ1(Q)=LϕL(Lr)ϕQ(QL)
  • Numbers:
τ1(q)=0.80.9+0.20.7=0.86,τ1(qc)=0.80.1+0.20.3=0.14.
  • Eliminate T
τ2(Q)=TϕT(TQ,r)ϕS(sQ,T)
  • Numbers:
τ2(q)=0.70.9+0.30.6=0.81,τ2(qc)=0.20.4+0.80.1=0.16.
  • Combine & normalize
h(Q)=τ1(Q)τ2(Q)h(q)=0.860.81=0.6966,h(qc)=0.140.16=0.0224.P(Q=qs,r)=h(q)h(q)+h(qc)=0.69660.6966+0.02240.9688.