R 中的概率谜题
Peter Chi
Assistant Professor of Statistics Villanova University

总可能数:
$$ n_1 \times n_2 \times \ldots \times n_k $$
示例:掷三颗骰子。配置总数:
$$ 6 \times 6 \times 6 = 6^3 $$
6^3
216
$k$ 个对象, 共 $n$ 种可能, 每种最多用一次
配置总数:
$$ n \times (n-1) \times ... \times (n-k+1) = \frac{n!}{(n-k)!} $$
示例:三颗骰子点数为 {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:三颗骰子得到 {2,3,4} 或 {3,4,5} 的概率
factorial(3)/6^3 + factorial(3)/6^3
0.05555556
示例 2:三颗骰子点数全相同的概率
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 中的概率谜题