马尔科夫链的稳态分布

import numpy as np


def steady_distribution(A, b, max_iter=100):
    y = A @ b
    count = 1
    while not (y == b).all() and count < max_iter:
        print(y)
        b = y
        y = A @ b
        count += 1


if __name__ == '__main__':
    matrix = np.array([[0.4, 0.5], [0.6, 0.5]])
    p = np.array([0.1, 0.9])
    steady_distribution(matrix, p)

posted @   crazypigf  阅读(15)  评论(0编辑  收藏  举报
 
点击右上角即可分享
微信分享提示
主题色彩