Esempio n. 1
0
def transform_point(point, transform):
    """transform a point"""
    hpoint = Vec(point)
    hpoint.append(1.0)
    hres = transform.mmul(hpoint)
    res = vector.vector(hres[0:-1]) / hres[-1]
    return res
Esempio n. 2
0
def transform_point(point, transform):
    """transform a point"""
    hpoint = Vec(point)
    hpoint.append(1.0)
    hres = transform.mmul(hpoint)
    res = vector.vector(hres[0:-1]) / hres[-1]
    return res
Esempio n. 3
0
 def transform(self, t):
     """returns a new configuration, which is this one transformed by matrix t"""
     newmap = {}
     for v in self.map:
         p = self.map[v]
         ph = Vec(p)
         ph.append(1.0)
         ph = t.mmul(ph)
         p = vector.vector(ph[0:-1]) / ph[-1]
         newmap[v] = p
     return Configuration(newmap)
Esempio n. 4
0
 def transform(self, t):
     """returns a new configuration, which is this one transformed by matrix t"""
     newmap = {}
     for v in self.map:
         p = self.map[v]
         ph = Vec(p)
         ph.append(1.0)
         ph = t.mmul(ph)
         p = vector.vector(ph[0:-1]) / ph[-1]
         newmap[v] = p
     return Configuration(newmap)
Esempio n. 5
0
def perp2D(v):
    w = Vec(v)
    w[0] = -v[1]
    w[1] = v[0]
    return w
Esempio n. 6
0
import hmm_forward
from matfunc import Table, Vec, Matrix

## example 10.2 from Li Hang's book (Statistical Learning Methods), pg. 177

a1 = Table([0.5, 0.2, 0.3])
a2 = Table([0.3, 0.5, 0.2])
a3 = Table([0.2, 0.3, 0.5])

A = Matrix([a1, a2, a3])
#print "matrix A is:\n", A

b1 = ([0.5, 0.5])
b2 = ([0.4, 0.6])
b3 = ([0.7, 0.3])

B = Matrix([b1, b2, b3])
#print "matrix B is:\n", B

pi = Vec([0.2, 0.4, 0.4])

T = 3
O = Table([0, 1, 0])  # red , white, red

print "The prob is:\n", hmm_forward.forward(A, B, pi, O)