我有一些由转移概率链接的状态(嵌入在转移矩阵中,如马尔可夫链中)。我想通过只考虑足够高的概率来总结这个转换矩阵,它们允许从一个状态(~节点)到另一个状态(我的转换矩阵中的第一个和最后一个)。一个阈值,如果我只考虑更高的概率,我的转换矩阵永远不允许从第一个状态(或节点)移动到最后一个状态。
两个问题:
是否有一些众所周知的库(最好是 python 语言)实现了这种方法?我的天真/经验/原型方法将是一个降低阈值值的循环,然后检查我是否可以从第一个状态流过转换矩阵到最后一个状态(距离矩阵中的最佳路径算法?)。但这可能需要非常高的计算时间?
Example 1:
DistMatrix = [[ 'a', 'b', 'c', 'd'],
['a', 0, 0.3, 0.4, 0.1],
['b', 0.3, 0, 0.9, 0.2],
['c', 0.4, 0.9, 0, 0.7],
['d', 0.1, 0.2, 0.7, 0]]
states are a,b,c,d. I want to find the value (threshold) that allow to go from a to d (no matter if other states are walked)
Naive approach:
- first loop: threshold 0.9, I get rid of lesser probabilities: I can only connect c and b
- second loop: threshold 0.7, I get rid of lesser probabilities: I can only connect c, b, d
- third loop: threshold 0.4, I get rid of lesser probabilities: I can connect a,c, b, d: here is my threshold: 0.4
--> 一旦我的转换矩阵有数千个状态,应该会非常复杂?--> 算法建议?
Example 2:
DistMatrix =
[ 'a', 'b', 'c', 'd'],
['a', 0, 0.3, 0.4, 0.7],
['b', 0.3, 0, 0.9, 0.2],
['c', 0.4, 0.9, 0, 0.1],
['d', 0.7, 0.2, 0.1, 0] ]
states are a,b,c,d. I want to find the value (threshold) that allow to go from a to d (no matter if other states are walked)
Naive approach:
-first loop: threshold 0.9, I get rid of all others: I can only connect c and b
-second loop: threshold 0.7, I get rid of lesser connexion: I connect b and c, and a and d but because a and d are connected, I have my threshold!