Projecteuler (280) Ant and seeds - 拼圖
By Yedda
at 2010-03-01T20:25
at 2010-03-01T20:25
Table of Contents
剛剛想到所有期望值形式上的算法。還是以三乘三為例 abc
def
ghi
馬可夫矩陣 起始狀態矩陣 (以b為例)
A= S=
0 1/3 0 1/3 0 0 0 0 0 a 0
1/2 0 1/2 0 1/4 0 0 0 0 b 1
0 1/3 0 0 0 1/3 0 0 0 c 0
1/2 0 0 0 1/4 0 1/2 0 0 d 0
0 1/3 0 1/3 0 1/3 0 1/3 0 e 0
0 0 1/2 0 1/4 0 0 0 1/2 f 0
0 0 0 1/3 0 0 0 1/3 0 g 0
0 0 0 0 1/4 0 1/2 0 1/2 h 0
0 0 0 0 0 1/3 0 1/3 0 i 0
在程式的例子中,每到終點(這裡以h為例)的機率不為零時,便
1.乘上目前步數 2.加到期望值 3.然後再將i 歸零。
事實上在3x3或5x5的例子中,零與非零輪流出現,因此這些操作每兩次就得進行一次。
例如第一次是取 (A^2)S 結果中的 h = 1/12
[POINT] 只把h歸零而其他機率不變的方法是乘上矩陣E (E for Elimination)
E=
0 1/3 0 1/3 0 0 0 0 0 a
1/2 0 1/2 0 1/4 0 0 0 0
0 1/3 0 0 0 1/3 0 0 0 .
1/2 0 0 0 1/4 0 1/2 0 0 .
0 1/3 0 1/3 0 1/3 0 1/3 0 .
0 0 1/2 0 1/4 0 0 0 1/2
0 0 0 1/3 0 0 0 1/3 0
0 0 0 0 0 0 0 0 0 h
0 0 0 0 0 1/3 0 1/3 0 i
跳結論,b→i的期望值
= 2 (A^2)S + 4 (AE)(A^2)S + 6 (AE)^2 (A^2)S + ... 即
__∞
╲
/ (2n+2) (AE)^n (A^2)S 的i那一項
 ̄ ̄n=0
然後這是個無窮級數 令原式=EXP, AE= P, (A^2)S = S'
EXP /2 = (Σ n P^n + Σ P^n) (A^2)S
_1 2 _1
=[ ((I-P) ) P + (I-P) P ] (A^2)S 媽呀,我竟然瘋到在PTT打數學式。
我們要的答案還是i那一項
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
這樣應該就可以直接算每種狀態的期望值(精確,還一定是有理數),然後isoneval大
的125X ......管他多少種,只要能有效列舉就一定能算出來。
不過我手邊沒有矩陣運算的工具XD WOW 25階方陣耶,我連四階以上反矩陣怎麼算都忘了
先在這裡掉隊啦。不知道utomaya大有沒有進展~~~
--
Tags:
拼圖
All Comments
By Genevieve
at 2010-03-02T08:58
at 2010-03-02T08:58
By Vanessa
at 2010-03-07T06:55
at 2010-03-07T06:55
By Regina
at 2010-03-11T00:12
at 2010-03-11T00:12
By Isabella
at 2010-03-11T19:25
at 2010-03-11T19:25
By Carol
at 2010-03-15T20:01
at 2010-03-15T20:01
By Oscar
at 2010-03-17T20:13
at 2010-03-17T20:13
By Edith
at 2010-03-18T04:43
at 2010-03-18T04:43
By Ethan
at 2010-03-22T18:37
at 2010-03-22T18:37
By Franklin
at 2010-03-27T14:55
at 2010-03-27T14:55
By Megan
at 2010-03-31T22:02
at 2010-03-31T22:02
By Franklin
at 2010-04-05T09:57
at 2010-04-05T09:57
By Edith
at 2010-04-08T19:23
at 2010-04-08T19:23
By Olive
at 2010-04-12T16:39
at 2010-04-12T16:39
By Olive
at 2010-04-15T08:36
at 2010-04-15T08:36
By George
at 2010-04-20T08:30
at 2010-04-20T08:30
By Daniel
at 2010-04-24T16:02
at 2010-04-24T16:02
By Kumar
at 2010-04-25T07:03
at 2010-04-25T07:03
Related Posts
Projecteuler連不上去
By Hedy
at 2010-03-01T19:33
at 2010-03-01T19:33
在32枚金幣中找假幣 by weiweililin
By Anthony
at 2010-03-01T10:57
at 2010-03-01T10:57
Projecteuler (280) Ant and seeds
By Noah
at 2010-03-01T10:10
at 2010-03-01T10:10
雷諾瓦Heye新品到貨
By Megan
at 2010-03-01T10:09
at 2010-03-01T10:09
五次內在32枚金幣中找假幣 solved by weiweililin
By Hamiltion
at 2010-03-01T01:49
at 2010-03-01T01:49