def getViterbiPath(self, table): #table[x][y][state][(sdx,sdy)] = (prob, previousStateId) _x = len(table) - 1 ((stateID, _sdx)), (prob, previousStateId) = \ recursiveArgMax( table[_x], selector=lambda x, y: max(x, y, key=lambda z: z[0] ) ) path = [(stateID, _x, _sdx, prob)] stateID = previousStateId while stateID >= 0: _x -= _sdx _sdx, (prob, previousStateId) = max( table[_x][previousStateId].iteritems(), key=lambda (_, (prob, __)): prob) path.append((stateID, _x, _sdx, prob)) stateID = previousStateId path.reverse() return path
def getViterbiPath(self, table): #table[x][y][state][(sdx,sdy)] = (prob, previousStateId) _x = len(table) - 1 ((stateID, _sdx)), (prob, previousStateId) = \ recursiveArgMax( table[_x], selector=lambda x, y: max(x, y, key=lambda z: z[0] ) ) path = [(stateID, _x, _sdx, prob)] stateID = previousStateId while stateID >= 0: _x -= _sdx _sdx, (prob, previousStateId) = max( table[_x][previousStateId].iteritems(), key=lambda (_, (prob, __)): prob ) path.append((stateID, _x, _sdx, prob)) stateID = previousStateId path.reverse() return path
def getViterbiPath(self, table): #table[x][y][state][(sdx,sdy)] = (prob, previousStateId) _x = len(table) - 1 _y = max([k for k in table[-1]]) (stateID, (_sdx, _sdy)), (prob, previousStateId) = \ recursiveArgMax( table[_x][_y], selector=lambda x, y: max(x, y, key=lambda z, _: z) ) path = [(stateID, (_x, _y), (_sdx, _sdy), prob)] stateID = previousStateId while stateID >= 0: _x -= _sdx _y -= _sdy (_sdx, _sdy), (prob, previousStateId) = max( table[_x][_y][previousStateId].iteritems(), key=lambda (_, (prob, __)): prob) path.append((stateID, (_x, _y), (_sdx, _sdy), prob)) stateID = previousStateId path.reverse() return path
def getViterbiPath(self, table): #table[x][y][state][(sdx,sdy)] = (prob, previousStateId) _x = len(table) - 1 _y = max([k for k in table[-1]]) (stateID, (_sdx, _sdy)), (prob, previousStateId) = \ recursiveArgMax( table[_x][_y], selector=lambda x, y: max(x, y, key=lambda z, _: z) ) path = [(stateID, (_x, _y), (_sdx, _sdy), prob)] stateID = previousStateId while stateID >= 0: _x -= _sdx _y -= _sdy (_sdx, _sdy), (prob, previousStateId) = max( table[_x][_y][previousStateId].iteritems(), key=lambda (_, (prob, __)): prob ) path.append((stateID, (_x, _y), (_sdx, _sdy), prob)) stateID = previousStateId path.reverse() return path