用 simulation 和 Markov Chain 都是 89/512

import numpy as np
from numpy.linalg import matrix_power

# Define the matrix
# States order: N, H, HH, T, TT, S
P = np.array([
    [0,   1/2, 0,   1/2, 0,   0  ],  # From N
    [0,   0,   1/2, 1/2, 0,   0  ],  # From H
    [0,   0,   0,   1/2, 0,   1/2],  # From HH
    [0,   1/2, 0,   0,   1/2, 0  ],  # From T
    [0,   1/2, 0,   0,   0,   1/2],  # From TT
    [0,   0,   0,   0,   0,   1  ]   # From S
])

# Number of powers to calculate
n = 11  # Change this value to compute up to P^n

# Compute and print powers of P
for i in range(1, n + 1):
    P_i = matrix_power(P, i)
    print(f"P^{i} using NumPy:\n", P_i)

所有跟帖: 

但楼主肯定不是要这么brutal force 的 解法 -run2022- 给 run2022 发送悄悄话 (0 bytes) () 01/04/2025 postreply 17:20:56

请您先登陆,再发跟帖!