編輯:似乎我的方法有效。
我遇到了一個編程問題,需要我計算達到終端狀態的概率。
經過幾個小時的艱苦努力試圖以傳統方式解決它,我用谷歌搜索并發現它被稱為吸收馬爾可夫鏈。并且有一個公式。
但是,我試圖弄清楚我的解決方案中缺少什么,因為它似乎是正確的。

恕我直言粗制濫造。該圖中基本上有4 個節點,黑線顯示原始轉換和概率,而彩色線顯示終止路徑。
步驟是這樣的:
追蹤所有可能到達終點的路徑,求出每條路徑到達終點的概率。那就是到達節點的概率。
忽略回圈路徑。這意味著從4到1的“1/3”轉換基本上被忽略了。
原因(2):因為我們可以假設回傳會以這樣一種方式增加每條可能路徑的概率,即它們仍然保持彼此相同的相對概率!例如,如果我從4回到1,那么去2、3和4的機會將分別增加1/27 (1/3 * 1/3 * 1/3),使得相對概率還是平等的!
我希望以上是有道理的。
- 將每個節點的概率計算為“每個節點的概率”/“終止的概率”,因為通過消除回圈圖,到達每個節點的概率將不再是 1。
因此,鑒于上述演算法,以下是找到的值:
紅色路徑:1/3
綠色路徑:1/3
藍色路徑:1/3 * 2/3 = 2/9
達到3 的
概率:1/3達到2 的概率:2/9 1/3 = 5/9
終止的總概率:1/3 5/9 = 8/9
因此,達到3 的最終概率:(1/3) / (8/9) = 3/8
最終達到2 的概率:(5/9) / (8/9) = 5/8
如果您對步驟(2)不確定,我們可以再試一次!
Assume that we went from 1 to 4 and back to 1 again, this has a probability of 1/9.
From here, we can follow each coloured paths again * 1/9 probability.
When combined with the probabilities calculated earlier, this gives us:
10/27 probability to reach 3.
50/81 probability to reach 2.
Total terminating probability of 80/81.
New probability of terminating at 3 is now (10/27) / (80/81) = 3/8 (SAME)
New probability of terminating at 2 is now (50/81) / (80/81) = 5/8 (SAME)
However, the actual probabilities are (2/5) and (3/5) for 3 and 2 respectively, using an algorithm I found online (there is a slim chance it is wrong though). Turns out I used the online solution wrongly
I realised my answer is actually pretty close, and I am not sure why is it wrong?
uj5u.com熱心網友回復:
我們可以用矩陣 表示馬爾可夫鏈的轉換M。在 Python 符號中,這看起來像:
M = [[ 0, 1/3, 1/3, 1/3],
[ 0, 1, 0, 0],
[ 0, 0, 1, 0],
[1/3, 2/3, 0, 0]])
以及向量的概率S,最初在狀態 1 中為 100%。
S = [1, 0, 0, 0]
將 S 乘以 M 給出新的概率:
S*M = [0, 1/3, 1/3, 1/3]
S*M**2 = [1/9, 5/9, 1/3, 0]
S*M**3 = [0, 16/27, 10/27, 1/27]
S*M**4 = [1/81, 50/81, 10/27, 0]
S*M**n = [3**(-n)*((-1)**n 1)/2,
3**(-n)*((-1)**n 5*3**n - 6)/8,
3**(-n)*(-(-1)**n 3*3**n - 2)/8,
3**(-n)*(1 - (-1)**n)/2]
在n趨向無窮大的極限中,對于 even n,這會給
[0, 5/8, 3/8, 0]
同樣以相同的概率從 1、2、3 和 4 開始:
S = [1/4, 1/4, 1/4, 1/4]
S*M = [1/12, 1/2, 1/3, 1/12]
S*M**2 = [1/36, 7/12, 13/36, 1/36]
S*M**n = [3**(-n)/4, 5/8 - 3*3**(-n)/8, 3/8 - 3**(-n)/8, 3**(-n)/4]
導致同樣的限制[0, 5/8, 3/8, 0]。
以等概率從 1 和 4 開始:
S = [1/2, 0, 0, 1/2]
S*M = [1/6, 1/2, 1/6, 1/6]
S*M**2 = [1/18, 2/3, 2/9, 1/18]
S*M**n = [3**(-n)/2, 3/4 - 3*3**(-n)/4, 1/4 - 3**(-n)/4, 3**(-n)/2]
給出了n去無窮大的另一個限制:
[0, 3/4, 1/4, 0]
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/362848.html
上一篇:如何僅使用一對xyfor回圈在浮點陣列中創建圓形輪廓
下一篇:將陣列結果添加到字串
