Commit a47169bf authored by Manuel Baum's avatar Manuel Baum
Browse files

Changed behaviour of ProbabilityTable.to_jpt_by_states back to origninal...

Changed behaviour of ProbabilityTable.to_jpt_by_states back to origninal behaviour, as is documented... I dont know who changed it
parent aafe2df0
......@@ -44,7 +44,7 @@ print pt
print "----burglary----"
print pt.marginalization(alarm)
print "----alarm----"
print pt.division(burglary.get_cpd())
#print pt.division(burglary.get_cpd())
bn.draw()
from primo.core import BayesNet
from primo.reasoning import GaussNode
from primo.reasoning import MarkovChainSampler
from primo.reasoning import GibbsTransitionModel
#Construct some simple BayesianNetwork. In this example it models
#the linear relationship between the age of a plant and the height that
#it has grown up to (+noise)
#topology
bn = BayesNet()
age = GaussNode("Plant_age")
height = GaussNode("Plant_height")
bn.add_node(age)
bn.add_node(height)
bn.add_edge(age,height)
#parameterization
age_b0=numpy.array([4])
age_variance=numpy.array([2])
age_b=numpy.array()
age.set_density_parameters(age_b0,age_b,age_variance)
height_b0=numpy.array([2])
height_variance=numpy.array([1.5])
height_b=numpy.array([2])
height.set_densitiy_parameters(height_b0, height_b, height_variance)
# -*- coding: utf-8 -*-
from primo.reasoning.density import Density
class CanonicalForm(Density):
'''TODO: write doc'''
def __init__(self):
super(CanonicalForm, self).__init__()
self.K=0
self.h=0
self.g=0
......@@ -87,7 +87,7 @@ class ProbabilityTable(Density):
def normalize_as_jpt(self):
'''This method normalizes this ProbabilityTable so it represents a valid joint probability table'''
return self.table * 1.0 / numpy.sum(self.table)
self.table = self.table * 1.0 / numpy.sum(self.table)
def multiplication(self, inputFactor):
'''This method returns a unified ProbabilityTable which contains the variables of both; the inputFactor
......
<?xml version="1.0" encoding="UTF-8"?>
<BIF VERSION="0.3">
<NETWORK>
<NAME>
Test Net
</NAME>
<VARIABLE TYPE="nature">
<NAME>
Weather
</NAME>
<OUTCOME>
Sun
</OUTCOME>
<OUTCOME>
Rain
</OUTCOME>
<PROPERTY>
position = (150, 200)
</PROPERTY>
</VARIABLE>
<VARIABLE TYPE="nature">
<NAME>
Weather0
</NAME>
<OUTCOME>
Sun
</OUTCOME>
<OUTCOME>
Rain
</OUTCOME>
<PROPERTY>
position = (150, 100)
</PROPERTY>
</VARIABLE>
<VARIABLE TYPE="nature">
<NAME>
Ice_Cream_Eaten
</NAME>
<OUTCOME>
True
</OUTCOME>
<OUTCOME>
False
</OUTCOME>
<PROPERTY>
position = (150, 300)
</PROPERTY>
</VARIABLE>
<DEFINITION>
<FOR>
Weather
</FOR>
<GIVEN>
Weather
</GIVEN>
<GIVEN>
Weather0
</GIVEN>
<TABLE>
0.7 0.3 0.5 0.5
</TABLE>
</DEFINITION>
<DEFINITION>
<FOR>
Weather0
</FOR>
<GIVEN>
Weather0
</GIVEN>
<TABLE>
0.6 0.4
</TABLE>
</DEFINITION>
<DEFINITION>
<FOR>
Ice_Cream_Eaten
</FOR>
<GIVEN>
Weather
</GIVEN>
<GIVEN>
Ice_Cream_Eaten
</GIVEN>
<TABLE>
0.9 0.1 0.2 0.8
</TABLE>
</DEFINITION>
</NETWORK>
</BIF>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment