import numpy as np
matrix = np.matrix([[0.9, 0.075, 0.025], [0.15, 0.8, 0.05], [0.25, 0.25, 0.5]], dtype=float)
vector1 = np.matrix([[0.3, 0.4, 0.3]], dtype=float)
for i in range(100):
vector1 = vector1 * matrix
print("Current round:", i + 1)
print(vector1)
60次后保持稳定
最终状态的概率分布趋于同一个稳定的概率分布[0.625 0.3125 0.0625]
import numpy as np
matrix = np.matrix([[0.9,0.075,0.025],[0.15,0.8,0.05],[0.25,0.25,0.5]], dtype=float)
for i in range(10):
matrix = matrix * matrix
print("Current round:" , i+1)
print(matrix)
第六次之后保持稳定
我们可以发现,在n≥6n≥6以后,PnPn的值稳定不再变化,而且每一行都为[0.625 0.3125 0.0625],这和我们前面的稳定分布是一致的。这个性质同样不光是离散状态,连续状态时也成立。