Rで解く確率パズル
Peter Chi
Assistant Professor of Statistics Villanova University

総数:
$$ n_1 \times n_2 \times \ldots \times n_k $$
【例】サイコロを 3 回振る。構成の総数:
$$ 6 \times 6 \times 6 = 6^3 $$
6^3
216
対象 $k$、 総通り数 $n$、 各通りは高々 1 回使用
構成の総数:
$$ n \times (n-1) \times ... \times (n-k+1) = \frac{n!}{(n-k)!} $$
【例】3 個のサイコロが {2,3,4} となる並べ方の数:
$$ 3 \times 2 \times 1 = \frac{3!}{(3-3)!} = 3! $$
factorial(3)
6
互いに排反な事象 $A$ と $B$ について:
$$ P(A \cup B) = P(A) + P(B) $$
【例 1】3 個のサイコロで {2,3,4} または {3,4,5} が出る確率
factorial(3)/6^3 + factorial(3)/6^3
0.05555556
【例 2】3 個のサイコロが同じ目になる確率
1/6^3 + 1/6^3 + 1/6^3 + 1/6^3 + 1/6^3 + 1/6^3
0.02777778
合計 $n$ 個の対象 $k$ 個を選ぶ・順序は不問
総数:
$$ {n \choose k} = \frac{n!}{k! \times (n-k)!} $$
【例】3 個のサイコロから 2 個を選ぶ方法数:
$$ {3 \choose 2} = \frac{3!}{2! \times (3-2)!} = 3$$
choose(3,2)
3
【例】サイコロを 10 回振る
同じ目が 5 個と別の目が 5 個になる方法数:
n_denom <- factorial(6) / factorial(4)
n_groupings <- choose(10,5) * choose(5,5)
n_total <- n_denom * n_groupings
n_total
7560
Rで解く確率パズル