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(S∣Q,T).
τ1(Q,T)=∑SϕS(S∣Q,T)=1(constant, drop it)
  • Remaining: {ϕR(R),ϕL(L∣R),ϕQ(Q∣L),ϕT(T∣Q,R)}.

  • Eliminate L

    • Multiply the factors with L and sum out L:
g2(L,R,Q)=ϕL(L∣R)ϕQ(Q∣L),τ2(R,Q)=∑Lg2(L,R,Q).τ2(R=r,Q=q)=0.8⋅0.9+0.2⋅0.7=0.86,τ2(R=rc,Q=q)=0.3⋅0.9+0.7⋅0.7=0.76,τ2(R=r,Q=qc)=0.8⋅0.1+0.2⋅0.3=0.14,τ2(R=rc,Q=qc)=0.3⋅0.1+0.7⋅0.3=0.24.
  • Eliminate R
    • Combine factors with R and sum out R:
g3(R,Q,T)=ϕR(R)τ2(R,Q)ϕT(T∣Q,R),τ3(Q,T)=∑Rg3(R,Q,T).
  • With P(R=r)=0.2, P(R=rc)=0.8:
τ3(Q=q,t)=0.2⋅0.86⋅0.7+0.8⋅0.76⋅0.9=0.1204+0.5472=0.6676,τ3(Q=qc,t)=0.2⋅0.14⋅0.2+0.8⋅0.24⋅0.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=q∣S=s,R=r)
  • Factorization & evidence
P(R,L,Q,T,S)=ϕR(R)ϕL(L∣R)ϕQ(Q∣L)ϕT(T∣Q,R)ϕS(S∣Q,T)
  • Evidence: R=r, S=s. Substitute to get factors
{ϕL(L∣r), ϕQ(Q∣L), ϕT(T∣Q,r), ϕS(s∣Q,T)}

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

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

  • Eliminate L

τ1(Q)=∑LϕL(L∣r)ϕQ(Q∣L)
  • Numbers:
τ1(q)=0.8⋅0.9+0.2⋅0.7=0.86,τ1(qc)=0.8⋅0.1+0.2⋅0.3=0.14.
  • Eliminate T
τ2(Q)=∑TϕT(T∣Q,r)ϕS(s∣Q,T)
  • Numbers:
τ2(q)=0.7⋅0.9+0.3⋅0.6=0.81,τ2(qc)=0.2⋅0.4+0.8⋅0.1=0.16.
  • Combine & normalize
h(Q)=τ1(Q)τ2(Q)h(q)=0.86⋅0.81=0.6966,h(qc)=0.14⋅0.16=0.0224.P(Q=q∣s,r)=h(q)h(q)+h(qc)=0.69660.6966+0.0224≈0.9688.