取得葫蘆的機率
當 5 顆骰子中有 3 顆點數相同,另外 2 顆為另一個相同點數時,稱為葫蘆。也就是由「三條」加上「一對」組成。範例如 {2,2,2,5,5}。
現在來計算在一次擲 5 顆骰子的情況下,得到「葫蘆」的機率。
本練習屬於課程
R 的機率謎題
練習說明
- 計算三條與一對合併後,可選的點數種類總數。
- 計算分組的方法數;也就是哪些骰子屬於三條、哪些屬於一對。
- 結合前兩步的數量,得到可形成葫蘆的可能數。
- 計算取得葫蘆的機率,然後將它印出。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
s_space <- 6^5
# Calculate the number of denominations possible
n_denom <- ___
# Calculate the number of ways to form the groups
n_groupings <- ___
# Calculate the total number of full houses
n_full_house <- ___
# Calculate and print the answer
p_full_house <- ___
print(p_full_house)