Last active
November 13, 2018 19:53
-
-
Save manvillej/b9cadb3eab076685547388554a8db7cc to your computer and use it in GitHub Desktop.
version 1 of get matrix function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> def getMatrix(matrix, turns): | |
... newMatrix = np.identity(matrix.shape[0]) | |
... for i in range(turns): | |
... newMatrix = newMatrix*matrix | |
... return newMatrix | |
>>> twoTurnMatrix = getMatrix(transitionMatrix,2) | |
>>> twoTurnMatrix | |
matrix([ | |
[2, 1, 0, 1, 0, 0, 0, 1, 0, 1], | |
[1, 2, 0, 1, 0, 0, 0, 1, 0, 0], | |
[0, 0, 2, 0, 1, 0, 1, 0, 0, 0], | |
[1, 1, 0, 2, 0, 0, 0, 0, 0, 1], | |
[0, 0, 1, 0, 3, 0, 1, 0, 1, 0], | |
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
[0, 0, 1, 0, 1, 0, 3, 0, 1, 0], | |
[1, 1, 0, 0, 0, 0, 0, 2, 0, 1], | |
[0, 0, 0, 0, 1, 0, 1, 0, 2, 0], | |
[1, 0, 0, 1, 0, 0, 0, 1, 0, 2]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment