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 (one per action) and a list 
dataset/ETHPy150Open pybrain/pybrain/pybrain/rl/learners/modelbased/policyiteration.py/collapsedTransitions