scientific-programming-exer.../ex_43.py

16 lines
340 B
Python

import numpy as np
P = np.array(
[ [1/6, 1/6, 1/6, 1/6, 1/6, 0]
, [1/6, 1/6, 1/6, 1/6, 1/6, 0]
, [1/6, 1/6, 1/6, 1/6, 1/6, 0]
, [1/6, 1/6, 1/6, 1/6, 1/6, 0]
, [1/6, 1/6, 1/6, 1/6, 1/6, 1/10]
, [1/6, 1/6, 1/6, 1/6, 1/6, 9/10]])
print(P.shape)
v = np.array([0, 1, 0, 0, 0, 0])
w = np.power(np.dot(P**4, v), 1/4)
print(w)
print(w[-1])