Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PRIMO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
Show more breadcrumbs
Social Cognitive Systems
PRIMO
Commits
26ca6d7f
Commit
26ca6d7f
authored
12 years ago
by
mbaumBielefeld
Browse files
Options
Downloads
Patches
Plain Diff
Did something in ProbabilityTable.division() but isnt finished
parent
2e42b1f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/MCMC.py
+2
-2
2 additions, 2 deletions
examples/MCMC.py
primo/reasoning/density/ProbabilityTable.py
+9
-1
9 additions, 1 deletion
primo/reasoning/density/ProbabilityTable.py
with
11 additions
and
3 deletions
examples/MCMC.py
+
2
−
2
View file @
26ca6d7f
...
@@ -29,7 +29,7 @@ transition_model = GibbsTransitionModel()
...
@@ -29,7 +29,7 @@ transition_model = GibbsTransitionModel()
mcs
=
MarkovChainSampler
()
mcs
=
MarkovChainSampler
()
initial_state
=
{
burglary
:
"
Safe
"
,
alarm
:
"
Silent
"
}
initial_state
=
{
burglary
:
"
Safe
"
,
alarm
:
"
Silent
"
}
chain
=
mcs
.
generateMarkovChain
(
bn
,
1000
000
,
transition_model
,
initial_state
)
chain
=
mcs
.
generateMarkovChain
(
bn
,
5
000
,
transition_model
,
initial_state
)
#for c in chain:
#for c in chain:
# print c
# print c
...
@@ -44,7 +44,7 @@ print pt
...
@@ -44,7 +44,7 @@ print pt
print
"
----burglary----
"
print
"
----burglary----
"
print
pt
.
marginalization
(
alarm
)
print
pt
.
marginalization
(
alarm
)
print
"
----alarm----
"
print
"
----alarm----
"
print
pt
.
division
(
burglary
)
print
pt
.
division
(
burglary
.
get_cpd
()
)
bn
.
draw
()
bn
.
draw
()
This diff is collapsed.
Click to expand it.
primo/reasoning/density/ProbabilityTable.py
+
9
−
1
View file @
26ca6d7f
...
@@ -173,7 +173,15 @@ class ProbabilityTable(Density):
...
@@ -173,7 +173,15 @@ class ProbabilityTable(Density):
def
division
(
self
,
factor
):
def
division
(
self
,
factor
):
'''
Returns a new ProbabilityTable which is the result of dividing this one by the one given
'''
Returns a new ProbabilityTable which is the result of dividing this one by the one given
with the argument factor
'''
with the argument factor
'''
divided
=
ProbabilityTable
()
variables
=
list
(
set
(
self
.
variables
)
|
set
(
factor
.
variables
))
for
variable
in
variables
:
divided
.
add_variable
(
variable
)
for
variable
in
variables
:
for
value
in
variable
.
get_value_range
():
index
=
"
lol
"
raise
Exception
(
"
Sorry, called unimplemented method ProbabilityTable.division()
"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
str
(
self
.
table
)
return
str
(
self
.
table
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment