Esempio n. 1
0
#Do some Inferences
evidence = {burglary: EvEq("Intruder")}

print "-------ProbabilityOfEvidence:-------"
poe = mcmc_ask.calculate_PoE(evidence)
print "p(evidence=Intruder)=" + str(poe)
print "Ground truth=0.2\n"

print "-------PosteriorMarginal:-------"
pm = mcmc_ask.calculate_PosteriorMarginal([alarm], evidence, ProbabilityTable)
print "P(alarm|burglary=Intruder)=" + str(pm)
print "Ground truth=[0.8, 0.15, 0.05]\n"

print "-------PriorMarginal:-------"
pm = mcmc_ask.calculate_PriorMarginal([alarm], ProbabilityTable)
print "P(Alarm)= " + str(pm)
print "Ground truth=[0.2, 0.75, 0.05]\n"

pm = mcmc_ask.calculate_PriorMarginal([burglary], ProbabilityTable)
print "P(Burglary)= " + str(pm)
print "Ground truth=[0.2, 0.8]\n"

print "-------MAP:-------"
hyp = mcmc_ask.calculate_MAP([alarm], evidence, ProbabilityTable)
print "MAP(alarm|burglary=intruder)=" + str(hyp)
print "Ground truth=\"Ringing\"\n"

hyp = mcmc_ask.calculate_MAP([burglary, alarm], {}, ProbabilityTable)
print "MAP(burglary,alarm)=" + str(hyp)
print "Ground truth=\"Safe\",\"Silent\"\n"
Esempio n. 2
0
print pm
print ""


print "------PosteriorMarginal:------"
pm=mcmc_ask.calculate_PosteriorMarginal([age,height],{age:EvEqual(2)},NDGauss)
print "P(age,height|age=2):"
print pm
print "Ground truth: age=2, height=mu:1.9,C=0.3"
print ""

pm=mcmc_ask.calculate_PosteriorMarginal([age,height],{age:EvLower(0.1)},NDGauss)
print "P(age,height|age<0.1):"
print pm
print "Ground truth: age=0:0.1, height=mu:-0.1:0.0,C=0.3"
print ""

print "------PropabilityOfEvidence------"
poe=mcmc_ask.calculate_PoE({age:EvLower(0.347)})
print "Probabilty that age is lower than it's median:"
print "p(age<0.347)="+str(poe)
print "Ground truth=0.5"
print ""

print "------MAP------"
map_hypothesis=mcmc_ask.calculate_MAP([height,diameter],{},NDGauss)
print map_hypothesis



Esempio n. 3
0
#Do some Inferences
evidence={burglary:EvEq("Intruder")}

print "-------ProbabilityOfEvidence:-------" 
poe=mcmc_ask.calculate_PoE(evidence)
print "p(evidence=Intruder)="+str(poe)
print "Ground truth=0.2\n"

print "-------PosteriorMarginal:-------"
pm=mcmc_ask.calculate_PosteriorMarginal([alarm],evidence,ProbabilityTable)
print "P(alarm|burglary=Intruder)="+str(pm)
print "Ground truth=[0.8, 0.15, 0.05]\n"

print "-------PriorMarginal:-------"
pm=mcmc_ask.calculate_PriorMarginal([alarm],ProbabilityTable)
print "P(Alarm)= " + str(pm)
print "Ground truth=[0.2, 0.75, 0.05]\n"

pm=mcmc_ask.calculate_PriorMarginal([burglary],ProbabilityTable)
print "P(Burglary)= " + str(pm)
print "Ground truth=[0.2, 0.8]\n"

print "-------MAP:-------"
hyp=mcmc_ask.calculate_MAP([alarm],evidence,ProbabilityTable)
print "MAP(alarm|burglary=intruder)=" + str(hyp)
print "Ground truth=\"Ringing\"\n"

hyp=mcmc_ask.calculate_MAP([burglary,alarm],{},ProbabilityTable)
print "MAP(burglary,alarm)="+str(hyp)
print "Ground truth=\"Safe\",\"Silent\"\n"