概率題: 飛機座位 (升級挑戰版)

75 回覆
1 Like 23 Dislike
2024-10-06 00:58:52
係咪裝個ide /compiler
放入去就run到
2024-10-06 01:26:04
你用咩機
Mac/linux的話直接去terminal compile就得
cc file_name.c -o file_name
./file_name

Windows嘅話裝C compiler好麻煩
一係你等我聽日寫個python version比你,十分鐘搞掂
2024-10-06 01:28:40
Windows
純粹有興趣學下 simulation
2024-10-06 01:56:20
n = 1, P(n) = 1
n = 2, P(n) = 1/2 = 1 - 1/2
n = 3, P(n) = 7/18 = 1 - 1/2 - 1/9
n = 4, P(n) seems to be 47/144 = 1 - 1/2 - 1/9 - 1/16
個 pattern 好似係 1/2 - 3^(-2) - 4(^-2)
鳩估條算式係 1/2 - 3^(-2) - 4^(-2) - 5^(-2) - ... - (n-1)^(-2) - n^(-2)
2024-10-06 02:13:47
你計左n=4?
睇下你點計

有冇人simulate下n=4 n=5嘅情況
2024-10-06 03:46:23
Sorry 頭先用筆算計錯咗
用 excel 窮舉法計多次,P(n = 4) = 1/3
2024-10-06 10:34:58
why
n = 3, P(n) = 1 - 1/2 - 1/9
2024-10-06 10:52:56
我simulation都計到1/3
Enter the number of passengers: 4
Enter the number of runs: 5000000
Success rate: 33.340280%

Enter the number of passengers: 5
Enter the number of runs: 50000000
Success rate: 29.462626%

Enter the number of passengers: 6
Enter the number of runs: 50000000
Success rate: 26.529514%
2024-10-06 11:17:19
Simulation係幾好玩
Python ver(慢C十倍)
2024-10-06 12:23:37
報告 P(n=5) 用 excel 窮舉計到 29.506173% (239/810)
巴打個 simulation 應該幾準
2024-10-06 12:29:08
我計錯數,其實無關係的,請巴打忘記佢
2024-10-06 12:43:22
Nice
不過我呢個最多3個sig fig
2024-10-07 02:38:32
受好奇心驅動 plot 咗個機率分佈
原來越多乘客,2號乘客越傾向坐返自己個位

同埋最後登機o既乘客,坐返自己個位o既機率
同坐喺原本 assign 俾1號客個位o既機率理論上係一樣
2024-10-07 04:20:21
點樣plot到咁exact
唔係用simulation?
2024-10-07 09:42:27
想問問個表係咩意思
what is the meaning of a cell that is in row I and column j
2024-10-07 09:56:50
用 power query 窮舉
再用 excel formula 計同 plot

整完後我更好奇係咪可以用 matrix generate
即係好似計 Markov chain 嗰啲咁
2024-10-07 10:31:22
Row P1, P2, P3...
代表第幾位上機嘅乘客

Column S1, S2, S3...
代表原本 assign 咗俾邊位乘客嘅座位
個數字對應返乘客上機嘅次序
同實際印喺登機證上面嘅座位編號無關
例如當班機總共有 6 位乘客
S6 代表最後一名登機乘客 P6 原本嘅座位

啲 cell 入面個百分比就係某位乘客最終坐喺某個位嘅機率
2024-10-07 10:35:38
我可能都唔係太明

如果乘客a佔用乘客b個位 咁其他所有人坐乘客b嘅位應該嘅機會係零
2024-10-07 10:38:26
你講緊嘅係某一個 scenario
呢個 plot 係綜合所有 scenario 之後得出嘅機率場
2024-10-07 10:39:25
Oh, so you mean that for row I and column J It means the I passenger on board will sit on the purchase seat of passenger J.
2024-10-07 10:40:00
Yes
2024-10-07 10:43:30
原來越多乘客,2號乘客越傾向坐返自己個位

This is very normal, because The possibility of the second passenger on board seating his own seat solely depends on the first passenger.
2024-10-07 10:45:25
Plot 咗個圖清晰啲
2024-10-07 14:23:22
2024-10-07 21:41:56
巴打見笑喇,我覺得你寫o既 simulation programme 更有用
吹水台自選台熱 門最 新手機台時事台政事台World體育台娛樂台動漫台Apps台遊戲台影視台講故台健康台感情台家庭台潮流台美容台上班台財經台房屋台飲食台旅遊台學術台校園台汽車台音樂台創意台硬件台電器台攝影台玩具台寵物台軟件台活動台電訊台直播台站務台黑 洞