假设你的音乐库中有 10 首歌曲,你想要随机播放所有歌曲(即这 10 首歌曲会以随机顺序播放)。你的音乐库可以有多少种不同的播放方式?
这种类型的题被称为有序选择(排列),因为我们是在选取音乐库中的歌曲并以特定顺序进行播放。例如,以下这些选择被认为是不同的:

这些明显地定义了不同的播放顺序,或实际上,不同的播放列表。
让我们逐步思考。我们可以从 10 首不同的歌曲中选择 1 首放在第一个位置(或播放的第一首歌曲),从剩下的 9 首歌曲中选择 1 首放在第二个位置(因为已经选了 1 首),从剩下的 8 首歌曲中选择 1 首放在第三个位置(因为已经固定了 2 首),以此类推。总的播放方式可以计算如下:

将近 400 万种不同的播放列表!
现在我们将介绍阶乘函数,它是一种表达以下内容的简便方法:

正式定义为:

因此,在我们的例子中:

如果我们有 30 首歌曲,但仍然只想要随机播放其中的 10 首呢?类似的推理得出以下结论:

种不同的方式。这等同于:

注意!阶乘函数不对加法或乘法进行分配。
一般来说,从n个项目中选取m个项目的排列数量(例如,从 30 首歌曲中选取 10 首)为:

其背后的原理是我们取消了n!乘积中除前m个因子以外的所有因子:

当m等于n时,我们说我们是在计算n个项目的排列数量。

在解决计数问题时,我们通常会使用“项目”或“元素”(在本例中为歌曲)以及“集合”(在本例中为集合或播放列表)这些词。
1. In how many ways can I arrange my bookshelf (7 books) if I own a trilogy and the 3 books have to be always together, in the same order?
2. In how many ways can I arrange my family (6 members) in a line, with the only rule that my parents have to be in adjacent positions?
用奇素数(即3、5或7)可以组成多少个不同的两位数?75、37、77、33都是可能的解。
这是一个排列的特殊情况,项目可以选择多次。通过计数,我们发现每个位置有3种可能性,因为数字可以重复。

9个不同的数字。
如果我们要从n个项目中选择m个,并且可能重复,那么会有

排列。
1. How many three-digit numbers can be formed with only prime digits, and odd digits may only be repeated twice?
我们可以用多少种方法让4个人(爱丽丝、鲍勃、查尔斯和唐纳德)围坐在一张圆桌旁?
这也是排列的另一种特殊情况,4个元素以环形顺序排列,排列的起点和终点是未定义的。
如果我们简单地计算

将会有一些重复。我们将重复计算每个独特的排列,因为像

被认为是等价的。请记住,圆桌没有起点。
有4个人椅子和4组等价排列,这并非巧合。
如果我们任意给椅子编号,我们可以通过循环整个布局来获得所有等价的排列。我们会循环多少次?有多少个椅子/位置?4个。
将我们的第一个意图除以4(即将4个等价布置分组)

6个唯一的布置。
另一种方法是强制定义布局的任意起点,换句话说,固定一个元素并排列剩下的3个元素

方法让四个人围坐在一张圆桌旁。
1. What if there are 7 people, but the table only has 5 chairs?
在数学课的15名学生中,将选出5名学生代表班级参加全校数学竞赛。有多少种方法可以选择这5名学生?
这种类型的问题称为无序选择(组合),因为选择学生的顺序并不重要。例如,以下选择被认为是等价的

如前所述,有

种方法以有序选择方式选择5名候选人,但对于每个不同的组合,有5!种有序选择(即相同的5名学生)。这意味着我们为每个组合都计算了5!次。因此,有

种方法选择5名学生代表班级。
一般来说,从n个项目中选择m个项目的种数为

我们拿出了从 *n* 个项目中选出 *m* 个项目的排列公式,然后除以 *m*!,因为每个组合都被计算了 *m*! 个有序的选择(*m*! 次)。
这个公式用以下符号表示:

注意,
通常读作 *从 n 中选 m*。
1. Try not to use a calculator and think of the problem with groups of 1 student.
2. Again, no calculator and this time there are 1 million students in the class and we want to form groups of 999,999 students.
在这种特殊的组合问题情况下,元素可以被选择多次。也就是说,组可以包含同一个元素的多个样本。
知道哪些元素被采样不足以定义一个选择,我们需要知道 **每个元素被选择的次数** (即该元素被选择的样本数量)。本质上,这两种方法是相同的,因为说一个元素被选择了 0 次等同于说它没有被采样。
现在假设我们要从 *n* 个元素中选出 *m* 个元素。我们不应该把这个问题看成是 "从 *n* 个元素中选择 *m* 次",而应该把它看成是 "将 *m* 个可用位置分配给 *n* 个不同的元素"(表示将 *m* 个元素放入 *n* 个集合中)。同样,这两种解释是等效的,因为元素被选择的次数由其对应集合中元素的数量表示。
为了定义一个选择,我们把每个集合中放入了与我们从该集合所代表的元素中选择的样本一样多的对象。我们可以创建一个字符串来标识选择,例如用一个方块来表示每个对象(样本),用一个短横线来表示集合边界

这意味着三个位置被分配给第一个元素,两个位置被分配给第二个元素,两个位置被分配给第三个元素。换句话说,该选择包含三个第一类元素,两个第二类元素,两个第三类元素。该字符串可以代表一个随机的五个字母组成的字母组,仅包含字母 A,B,C

连接的字符串由 *m* 个方块和 *n + 1* 个短横线组成。例如,以下代表从五个元素中选出的三个元素

注意,除了固定在字符串开头和结尾的两个短横线外,其他 *n - 1* 个短横线和 *m* 个方块可以移动,而不会使字符串无效。因此,在 *n - 1 + m* 个位置中,有 *n - 1 + m* 个可移动字符。可能的字符串数量等于将 *m* 个方块放在 *n - 1 + m* 个字符中的方法数量,换句话说,是从 *n - 1 + m* 个位置中选出 *m* 个位置的方法数量

等效地,我们可以谈论将 *n - 1* 个短横线放在 *n - 1 + m* 个字符中的位置

由于每个字符串都独一无二地确定一个选择或组,因此字符串的数量显然等同于可能的组或选择的数量。
如果我们要为长途旅行打包三种水果,而你只有香蕉、苹果、橙子、桃子和奇异果,那么会有

可能的打包组。
二项式系数

表示从包含n个元素的集合中选择m个元素可以形成的无序组的数量。
以下是一些基本且有用的属性
- 从n个元素中选择m个元素的方式数量等于从n个元素中选择n-m个元素的方式数量,因为每个选定元素组都有一个相应的未选定元素组。选定元素组定义了另一个未选定元素组。




- 和

- 在于第一个公式没有计算包含在第二个公式中添加的元素的组。包含来自包含n+1个元素的集合中的特定元素的m大小的组的数量是

- 因此


- 和

- 在于第一个公式计算的组比第二个公式计算的组多一个元素。每个m大小的组需要n-m中剩余的“缺失”元素中的一个才能增长到m+1大小。

- 但是,我们必须观察到我们多次计算每个m+1大小的组,实际上是m+1次。这是因为“缺失”的元素可以是结果组中的m+1个元素中的任何一个,换句话说,m+1个m大小的组(当与正确的元素关联时)将形成同一个m+1大小的组。从m+1大小的组中移除一个元素可以形成多少个m大小的组?

- 这表明

二项式定理描述了以下表达式的代数展开

例如,取 *n* = 2,我们将尝试手动展开表达式,得到

取 *n* = 3

在展开过程中,我们故意没有对表达式进行简化。正如你所看到的,最终展开的形式分别有四项和八项。这些项都是 *a* 和 *b* 在两个和三个因子的乘积中所有可能的组合。
因子的数量等于第一个乘积中二项式 *(a + b)* 的数量,而这反过来又等于 *n*。
在

中,每一项都有 *n* 个因子。有多少项只有一个 *b*?换句话说,我可以在 *n* 个不同位置中放置一个 *b* 有多少种方法?或者更好的是,我可以在 *n* 个位置中选择一个位置(放置一个 *b*)有多少种方法?

类似地,我们可以计算出其他所有项的系数

更一般地说

或者更简洁地使用求和运算符
