def collapsedTransitions(Ts, policy):
 res = zeros_like(Ts[0])
 dim = len(Ts[0])
 for (ai, ap) in enumerate(policy.T):
  res += (Ts[ai] * repmat(ap, dim, 1).T)
 return res

def collapsedTransitions ( Ts , policy ) : res = zeros_like ( Ts [ 0 ] ) dim = len ( Ts [ 0 ] ) for ( ai , ap ) in enumerate ( policy . T ) : res += ( Ts [ ai ] * repmat ( ap , dim , 1 ) . T ) return res
collapses a list of transition matrices and a list of action probability vectors into a single transition matrix .