print "\n=== Homework 6.1 ==="
OBSERVATIONS = (("A", "B", "C", "A", "B", "C"), ("A", "A", "B", "B", "C", "C"),
                ("A", "A", "A", "C", "C", "C"))
t = TransProb(OBSERVATIONS)
t.report()

print "\n=== Homework 6.2 ==="
CHAIN = ("A", 1.0, {True: 0.9, False: 0.5})
c = MarkovChain(CHAIN)
print "stationary distribution: P(A) = %.4f" % c.stationary_distribution(True)
print "stationary distribution: P(B) = %.4f" % c.stationary_distribution(False)

print "\n=== Homework 6.3 ==="
MODEL = ("A", 0.5, {True: 0.5, False: 0.5}, "X", {True: 0.1, False: 0.8})
m = MarkovModel(MODEL)
m.p({"A0": True}, {"X0": True})
m.p({"A1": True}, {"X0": True})
m.p({"A1": True}, {"X0": True, "X1": True})

print "\n=== Homework 6.11 ==="
from Game.game import Game
HW6_11 = {
    "players": (("B", "d", "e", "f"), ("A", "a", "b", "c")),
    "matrix": (
        ((3, 3), (5, 0), (2, 1)),
        ((2, 4), (7, 8), (4, 6)),
        ((7, 5), (8, 5), (5, 3)),
    )
}
g = Game(HW6_11)
Beispiel #2
0
c.p({"A1":True})
c.p({"A2":True})
c.p({"A3":True})
print "stationary distribution: P(A) = %.4f" % c.stationary_distribution()

print "\nTransition Probabilities 1"
TRANSITIONS = [("R","S","S","S","R","S","R")]
t = TransProb(TRANSITIONS)
t.report()

print "\nTransition Probabilities 2"
TRANSITIONS = [("S","S","S","S","S","R","S","S","S","R","R")]
t = TransProb(TRANSITIONS)
t.report()

print "\nTransition Probabilities 3"
TRANSITIONS = [("R","S","S","S","S")]
t = TransProb(TRANSITIONS)
t.report(k=1)

print "\nMarkov Model 1"
MODEL = ("R", 0.5, {True: 0.6, False: 0.2}, "H", {True: 0.4, False: 0.9})
m = MarkovModel(MODEL)
m.p({"R1":True})
m.p({"R1":True}, {"H1":True})

print "\nMarkov Model 2"
MODEL = ("R", 1.0, {True: 0.6, False: 0.2}, "H", {True: 0.4, False: 0.9})
m = MarkovModel(MODEL)
m.p({"R1":True}, {"H1":True})
    ("A", "B", "C", "A", "B", "C"),
    ("A", "A", "B", "B", "C", "C"),
    ("A", "A", "A", "C", "C", "C")
)
t = TransProb(OBSERVATIONS)
t.report()

print "\n=== Homework 6.2 ==="
CHAIN = ("A", 1.0, {True: 0.9, False: 0.5})
c = MarkovChain(CHAIN)
print "stationary distribution: P(A) = %.4f" % c.stationary_distribution(True)
print "stationary distribution: P(B) = %.4f" % c.stationary_distribution(False)

print "\n=== Homework 6.3 ==="
MODEL = ("A", 0.5, {True: 0.5, False: 0.5}, "X", {True: 0.1, False: 0.8})
m = MarkovModel(MODEL)
m.p({"A0":True}, {"X0":True})
m.p({"A1":True}, {"X0":True})
m.p({"A1":True}, {"X0":True, "X1":True})

print "\n=== Homework 6.11 ==="
from Game.game import Game
HW6_11 = {
    "players": (
        ("B", "d", "e", "f"),
        ("A", "a", "b", "c")
    ),
    "matrix": (
        ((3,3), (5,0), (2,1)),
        ((2,4), (7,8), (4,6)),
        ((7,5), (8,5), (5,3)),