def fromMatrix(stateObjs,*transProbsPerState): ''' returns a new Chain instance from given arguments stateObjs is a sequence of objects representing states (strings, usually); transProbsPerState arguments contain the transiiton probability weights; there is one such argument per state, it is a tuple (stateObj,transProbs) where transProbs is the sequence of probability weights of transition from stateObj to each declared state, in the order of their declarations ''' nextStateLeas = (Alea.fromValFreqs(*zip(stateObjs,transProbs)) for (stateObj,transProbs) in transProbsPerState) nextStateLeaPerState = tuple(zip(stateObjs,nextStateLeas)) return Chain(nextStateLeaPerState)