Bayesian Belief Network - help pls

No.11563543 ViewReplyOriginalReport
I got that BBN and I have to answer this questions using python library pymc3.

What's the probability that:
1. will alarm turn on?
2. there was a burglary if you know the alarm has been turned on?
3. there was a earthquake if you know the alarm has been turned on?
4. in case of burglary someone will call?
5. burglary notification is false?
6. the alarm went off, with no earthquake or burglary, but both John and Mary called? (unconditional probability)

I have the code for the first three questions, but I have no idea how to do rest of them. Can you help, please?

with pm.Model() as alarm_model:
burglary = pm.Bernoulli('burglary', 0.01)
earthquake = pm.Bernoulli('earthquake', 0.02)

alarm_p = pm.Deterministic('alarm_p', pm.math.switch(earthquake, pm.math.switch(burglary, 0.95, 0.29), pm.math.switch(burglary, 0.94, 0.001)))
alarm = pm.Bernoulli('alarm', alarm_p)

johnCalls_p = pm.Deterministic('johnCalls_p', pm.math.switch(alarm, 0.90, 0.05))
johnCalls = pm.Bernoulli('johnCalls', johnCalls_p)

maryCalls_p = pm.Deterministic('maryCalls_p', pm.math.switch(alarm, 0.70, 0.01))
maryCalls = pm.Bernoulli('maryCalls', maryCalls_p)

trace = pm.sample(20000, chains=1)

# first
p_alarm = trace['alarm'].sum()/len(trace['alarm'])
print('p_alarm:', p_alarm)

# second
p_burglary_alarm = (trace['burglary']*trace['alarm']).sum()/trace['alarm'].sum()
print('p_burglary_alarm:', p_burglary_alarm)

# third
p_earthquake_alarm = (trace['earthquake']*trace['alarm']).sum()/trace['alarm'].sum()
print('p_earthquake_alarm:', p_earthquake_alarm)