常见的计数模型

常见的计数模型

  • 下面介绍的计数模型是基于基本计数原理(加法原理和乘法原理)

概念准备

多重集
  • 概念准备:multiset(多重集):元素可重复集合
  • 普通集合不允许包含重复元素,而元素可重复集合允许出现重复元素
  • In mathematics, a multiset (or bag, or mset) is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements.
重数
  • The number of instances given for each element is called the multiplicity(重数) of that element in the multiset.
  • As a consequence, an infinite number of multisets exist which contain only elements a and b, but vary in the multiplicities of their elements:(存在无数多个仅包含a,b两种元素的多重集)
    • The set {a, b} contains only elements a and b, each having multiplicity 1 when {a, b} is seen as a multiset.
    • In the multiset {a, a, b}, the element a has multiplicity 2, and b has multiplicity 1.
    • In the multiset {a, a, a, b, b, b}, a and b both have multiplicity 3.
相等多重集
  • 多重集关系元素数量,但是不关心元素顺序,意思是说,判断两个多重集A={ a 1 , a 2 , ⋯   , a n a_1,a_2,\cdots,a_n a1,a2,,an},B={ b 1 , b 2 , ⋯   , b m b_1,b_2,\cdots,b_m b1,b2,,bm}是否相等,可以这么做:
    • 尽管多重集不关心集内元素顺序,但是为了比较不同的多重集是否相等,我们仍然可以采用一定规则对其排序,使得多重集之间比较起来更直观和容易
    • 设A中包含m种元素,第i种元素的排序优先级定为i级,i越小,排的越前面
    • A=A’={ a 1 [ 1 ] , ⋯   , a n 1 [ 1 ] a^{[1]}_1,\cdots,a_{n_1}^{[1]} a1[1],,an1[1]; a 1 [ 2 ] , ⋯   , a n 2 [ 2 ] a^{[2]}_1,\cdots,a_{n_2}^{[2]} a1[2],,an2[2]; ⋯ \cdots ; a 1 [ m ] , ⋯   , a n m [ m ] a^{[m]}_1,\cdots,a_{n_m}^{[m]} a1[m],,anm[m]};其中 ∑ i = 1 m n i = n \sum_{i=1}^{m}n_i=n i=1mni=n
    • B=B’={ b 1 [ 1 ] , ⋯   , b t 1 [ 1 ] b^{[1]}_1,\cdots,b_{t_1}^{[1]} b1[1],,bt1[1]; b 1 [ 2 ] , ⋯   , b t 2 [ 2 ] b^{[2]}_1,\cdots,b_{t_2}^{[2]} b1[2],,bt2[2]; ⋯ \cdots ; b 1 [ m ] , ⋯   , b t m [ m ] b^{[m]}_1,\cdots,b_{t_m}^{[m]} b1[m],,btm[m]},其中 ∑ i = 1 m t i = n \sum_{i=1}^{m}t_i=n i=1mti=n
    • n i = t i n_i=t_i ni=ti,记为 k i k_i ki; a j [ i ] a_{j}^{[i]} aj[i]= b j [ i ] b_{j}^{[i]} bj[i],其中 i = 1 , 2 , ⋯   , m i=1,2,\cdots,m i=1,2,,m, j = 1 , 2 , ⋯   , k i j=1,2,\cdots,k_i j=1,2,,ki,则 A = B A=B A=B
  • 这部分内容为带重复元素的组合问题(k重组合问题)做铺垫,帮助我们清晰地统计k重组合数
势(数学)
  • 势 (数学) (wikipedia.org)
  • 势,也称浓度(英语:Cardinality)在数学里是指如果存在着从集合A到集合B的双射,那么集合A与集合B等势,记为A~B。一个有限集的元素个数是一个自然数,势标志着该集合的大小。对于有限集,势为其元素的数量。比较无穷集里元素的多寡之方法,可在集合论里用集合的等势和某集合的势比另一个集合大这两个概念来达到目的。
    • A A A B B B为集合。称它们等势,指的是存在 A A A B B B一个双射 f f f,即 A A A中的元素可以与 B B B中的元素一一对应起来。例子:集合 A = { 1 , 2 , 3 } {\displaystyle A=\{1,2,3\}} A={1,2,3} B = { {\displaystyle B=\{} B={苹果,马,园丁 } \} }等势,这是因为“ 1 → {\displaystyle 1\rightarrow } 1苹果, 2 → {\displaystyle 2\rightarrow } 2马, 3 → {\displaystyle 3\rightarrow } 3园丁”是两个集合之间的一一对应。不过在这个例子中, 不用等势的概念也知道它们的元素不多不少, 是3个。
    • 对于无穷集可举一个例子如下:正偶数集合 E = { 2 , 4 , 6 , … } {\displaystyle E=\{2,4,6,\ldots \}} E={2,4,6,}和自然数集合 N = { 1 , 2 , 3 , … } {\displaystyle \mathbb {N} =\{1,2,3,\ldots \}} N={1,2,3,}等势,这是因为由公式 f ( n ) = 2 n {\displaystyle f(n)=2n} f(n)=2n所决定的函数 f : N → E {\displaystyle f:\mathbb {N} \rightarrow E} f:NE是一个由 N \mathbb{N} N E E E的双射。
  • 等势的概念只能说明两个(有限或无限)集合的元素是否“一样多”的问题。那么以下说明集合 A A A的元素是否比集合 B B B“多”的问题。
    • 称“集合 A A A的势不小于集合 B B B的势”,若存在一个由 B B B A A A的单射。
    • 称“集合 A A A的势大于集合 B B B的势”,若 A A A的势不小于 B B B的势,但 A A A B B B不等势。
      • 也就是说,存在一由 B B B A A A的单射,但它们之间不存在一一对应。
      • 例如,实数集合 R \mathbb {R} R的势严格大于自然数集合 N \mathbb{N} N的势,因为内含映射 i : N → R {\displaystyle i:\mathbb {N} \rightarrow \mathbb {R} } i:NR是单射的,且可证明不存在一由 N \mathbb{N} N R \mathbb {R} R的双射函数。
可数与不可数集合🎈
  • 假设选择公理成立,三分法就会成立于所有的势中,所以可以有以下的定义。
    1. 任何势小于自然数集的集合称为有限集合。
    2. 任何势和自然数集一样的集合称为可数无限集合。
    3. 任何势大于自然数集的集合称为不可数集合。

方幂模型

  • 在概率论中,对应于两种古典概型

    • 不放回抽样
    • 独立重复试验
  • k次抽样或试验,每次试验结果记为 x i ; x_i; xi;设每次基础试验的结果有n种

    • k次试验的总结果记为 ( x 1 , x 2 , ⋯   , x k ) (x_1,x_2,\cdots,x_k) (x1,x2,,xk)
    • 则可以产生出 n k n^k nk种结果
  • Note:方幂模型基于乘法原理,如果事情分为m步,每个步骤都有t种办法,那么完成整件事情有 t m t^m tm种方法

    • 但是要求这m个步骤必须相互独立,否则就不能使用方幂模型计数
    • 如果将某一个的包含m个步骤的方法的执行顺序打乱 但结果相同,则不能用方幂模型计算
    • 在允许空盒的隔板问题中,例如2个球放入2个盒子中(允许闲置某些空盒),
      • 00|
        • 00||
        • 0|0|
        • “|00|”
      • 0|0
        • 0|0|
        • 0||0
        • |0|0
      • |00
        • “|00|”
        • |0|0
        • ||00
      • 容易知道,两个球插入第一个隔板有3种位置可能;由于隔板之间不做区分,插入第2个隔板仍有3种可能
      • 按照这个思路,将会产生9种 3 2 3^2 32种可能;但是其中包含重复的情况:
        • |00|
        • 0|0|
        • |0|0

不尽相异物排列

  • ref:不尽相异元素的全排列 baidu.com)

  • "不尽相异物"这个词用的不多,主要是台湾那边的说法

  • 这类模型描述:被排列 n n n个元素中有 m m m个种类,同种类内的所有元素完全一致,记 C i C_i Ci类元素 n i n_i ni个, i = 1 , 2 , ⋯   , m i=1,2,\cdots,m i=1,2,,m,那么对这 n n n个元素的排列数记为 P = P n , ( n 1 , ⋯   , n m ) n P=P_{n,(n_1,\cdots,n_m)}^n P=Pn,(n1,,nm)n

  • 可以分两步计算 P P P:

    • 相异假设:将被排列的所有元素看作是互不相同的(即 C i C_i Ci类的 n i n_i ni元素被假设为可区分),那么有 P n n P_n^n Pnn种排列

    • 去序还原:由于同类别的元素实际上是不可区分的,所以按照相异假设处理会重复计入相同的排列;容易知道, C i C_i Ci类元素可以产生 P n n P_n^n Pnn个相同的重合排列,则 P n n P n i n i \frac{P_n^n}{P_{n_i}^{n_i}} PniniPnn表示去除了因为 C i C_i Ci类元素的 n i n_i ni个元素的不同摆放顺序导致的重复计数(根据乘法原理,可以分为m个大步骤,每个步骤表示排列 C i C_i Ci类元素的 n i n_i ni个元素)

    • 类似的,对 m m m个种类进行去序,得 P P P= P n n P n 1 n 1 P n 2 n 2 ⋯ P n m n m \frac{P_n^n}{P_{n_1}^{n_1}P_{n_2}^{n_2}\cdots{P_{n_m}^{n_m}}} Pn1n1Pn2n2PnmnmPnn

    • 用阶乘改写,得到
      P n , ( n 1 , ⋯   , n m ) n = n ! n 1 ! n 2 ! ⋯ n m ! = n ! ∏ i = 1 m n i ! P_{n,(n_1,\cdots,n_m)}^n=\frac{n!}{n_1!n_2!\cdots n_m!} =\frac{n!}{\prod_{i=1}^{m}n_i!} Pn,(n1,,nm)n=n1!n2!nm!n!=i=1mni!n!

插空法🎈

  • 在组合数学中,插空法是排列组合的推广,主要用于解决不相邻组合与追加排列的问题。
  • 插空法与隔板法的原理一样。
例子
  • 若有A,B,C,D,E五个人排队,要求A和B两个人必须不站在一起,则有多少种排队方法?
    • 首先将CDE三个人排列,有 P 3 3 = 6 P_{3}^{3}=6 P33=6种排法,若排成DCE,□D□C□E□有4个空,让A,B插空有 P 2 4 = 12 {\displaystyle P_{2}^{4}=12} P24=12种排法,总排法为 P 3 3 P 2 4 = 72 {\displaystyle P_{3}^{3}P_{2}^{4}=72} P33P24=72
  • 在一张节目单中原有6个节目,若保持这些节目相对顺序不变,再添加进去3个节目,则所有不同的添加方法共有多少种?
    • □1□2□3□4□5□6□有7个空,插第7个节目,
    • □1□2□3□4□5□6□7□有8个空,插第8个节目,
    • □1□2□3□4□5□6□7□8□有9个空,再插第9个节目,总排法为 7 × 8 × 9 7\times 8\times 9 7×8×9

带重复元素的组合问题(K-MC)

  • Number of combinations with repetition

  • A k-combination with repetitions, or k-multicombination, or multisubset of size k from a set S of size n is given by a set of k not necessarily distinct elements of S, where order is not taken into account:(为方便起见,下面用k-multicombinationk-MC来指代这类问题)

    • two sequences define the same multiset if one can be obtained from the other by permuting the terms.
  • In other words, it is a sample of k elements from a set of n elements allowing for duplicates (i.e., with replacement) but disregarding different orderings (e.g. {2,1,2} = {1,2,2}).

  • Associate an index to each element of S and think of the elements of S as types of objects, then we can

    • let x i x_{i} xi denote the number of elements of type i i i in a multisubset. ( i = 1 , 2 , ⋯   , n i=1,2,\cdots,n i=1,2,,n)
    • The number of multisubsets of size k is then the number of nonnegative integer (so allowing zero) solutions(解,这里是解向量 ( x 1 , ⋯   , x n ) (x_1,\cdots,x_n) (x1,,xn)) of the Diophantine(丢番图) equation:
      • x 1 + x 2 + … + x n = k . {\displaystyle x_{1}+x_{2}+\ldots +x_{n}=k.} x1+x2++xn=k.
    • If S has n elements, the number of such k-multisubsets is denoted by: (  ⁣ ⁣ ( n k )  ⁣ ⁣ ) {\displaystyle \left(\!\!{\binom {n}{k}}\!\!\right)} ((kn))
    • 这里要注意以下 n , k n,k n,k的含义,有些地方字母 n , k n,k n,k的含义于此处介绍的恰好相反
  • a notation that is analogous to the binomial coefficient which counts k-subsets.

  • This expression, n multichoose k, can also be given in terms of binomial coefficients:

    • (  ⁣ ⁣ ( n k )  ⁣ ⁣ ) = ( n + k − 1 k ) . {\displaystyle \left(\!\!{\binom {n}{k}}\!\!\right)={\binom {n+k-1}{k}}.} ((kn))=(kn+k1).
  • This relationship can be easily proved using a representation known as stars and bars.

问题描述👺
  • 从n种元素中取出k个元素构成的多重集个数

    • 设其中n种元素都是取不尽的(或者立即为:对n种球有放回地取k次球,将k次取球记录作为一次完整地操作过程)
  • 另一种描述是n元多项式方程 ∑ i = 1 n x i = k \sum_{i=1}^{n}x_i=k i=1nxi=k, x i ∈ N x_i\in\mathbb{N} xiN的解 ( x 1 , ⋯   , x n ) (x_1,\cdots,x_n) (x1,,xn)的个数

  • 将这个问题的个数解记为 S = ( ( n k ) ) S=(\binom{n}{k}) S=((kn))

问题示例
  • 以取色球为例,每种颜色的球有无限多颗,从8种色球中取出5颗球
    • 为了便于比较取出的组合之间是否相等以便避免重复计数,将取出的5个球进行按照一定的颜色优先级进行分档排列,例如某次取的5个球有三种颜色:
      • 第1种色球(红)取1颗,第2种色球(蓝)取2颗,第3种色球(绿色)取2颗
    • 在5颗球间画上分隔号“|”代表球色的分布情形:
      • 这种情况可以表示成:球|球球|球球| | | | |(或者红|蓝蓝|绿绿)
    • 可以理解为8类球每类取多少个,一起构成5个球。我们把5个球排成一排,用7个分隔线去隔开,每个分割线分割两类球。取出的5个球可能分布在7个分割线中任意一条的任意一侧
    • 如上图,表示含义:第1根线前表示第一类球取的个数,第1根和第2根线表示第二类球取的个数…第6第7根线前表示第七类球的个数,第7根后表示第八类球的个数。
隔板和空间划分
  • 一个板的可以将一个空间划分为两个部分,因为一个板有两侧
  • 如果有 m m m个板,可以划分出 m + 1 m+1 m+1个空间
  • 如果需要分割n个空间,需要 n − 1 n-1 n1个板
问题抽象
  • 现在,将上一小节的问题转换为:7个板分割出8个空间内投入5个球,可以产生多少种可能?
    • 设可能产生 S = ( ( n k ) ) S=(\binom{n}{k}) S=((kn))种可能(符号 ( ( ) ) (()) (()))是专门用来表示这类问题的解
    • ( 8 5 ) \binom{8}{5} (58)是错误的,5个球不总是落在不同的空间中,某个空间内也可能落入多个球
    • 5 8 5^8 58也是错误的,这会重复计算某些情况,例如记"第1个球落入空间1,第2个球落入空间2"为 ( 1 , 1 ) ; ( 2 , 2 ) (1,1);(2,2) (1,1);(2,2),那么使用方幂计算将 ( 1 , 1 ) ; ( 2 , 2 ) (1,1);(2,2) (1,1);(2,2) ( 2 , 1 ) ; ( 2 ; 2 ) (2,1);(2;2) (2,1);(2;2)当作两种情况;这在单重组合情况下是对的,但是多重组合,两种情况是只能计数1次,因为这两种情况结果都是空间1,2各有1个球,球与球的区别不被关心(球的颜色已经被转换为8个空间,这里球之见的区别不被关心,因此不能用方幂计算)
    • 算法1和算法2的问题分别是少算和多算
  • 不妨将 8 − 1 = 7 8-1=7 81=7个完全相同的板和需要5个完全一致的球视为可排列的对象
    • 表达式 A 8 − 1 + 5 5 A_{8-1+5}^{5} A81+55表示:假设7个板是相互区别的和5个球之间也是相互区别的,从而对这些对象的取k排列数是 A 12 5 A_{12}^{5} A125
    • 上述表达式会重复计数 7 ! 7! 7! 5 ! 5! 5!倍的S,为了不重复计数需要除以重复倍式来求得S,即 S = ( 8 − 1 + 5 ) ! 7 ! ⋅ 5 ! S=\frac{(8-1+5)!}{7!\cdot 5!} S=7!5!(81+5)!= 95040 95040 95040
总结为公式👺
  • ( ( n k ) ) = [ ( n − 1 ) + k ] ! ( n − 1 ) ! k ! = ( n + k − 1 k )    ( 1 ) = ( n + k − 1 n − 1 )    ( 2 ) \begin{aligned} \left(\binom{n}{k}\right) =&\frac{[(n-1)+k]!}{(n-1)!k!}\\ =&\binom{n+k-1}{k}\;(1)\\ =&\binom{n+k-1}{n-1}\;(2) \end{aligned} ((kn))===(n1)!k![(n1)+k]!(kn+k1)(1)(n1n+k1)(2)

  • 根据组合数的性质, ( n k ) \binom{n}{k} (kn)= ( n n − k ) \binom{n}{n-k} (nkn),所有公式有上述两种形式

其他性质
  • As with binomial coefficients, there are several relationships between these multichoose expressions. For example, for n ≥ 1 , k ≥ 0 n\geq 1,k\geq 0 n1,k0,

  • (  ⁣ ⁣ ( n k )  ⁣ ⁣ ) = (  ⁣ ⁣ ( k + 1 n − 1 )  ⁣ ⁣ ) . {\displaystyle \left(\!\!{\binom {n}{k}}\!\!\right)=\left(\!\!{\binom {k+1}{n-1}}\!\!\right).} ((kn))=((n1k+1)).

    • ( ( k + 1 n − 1 ) ) = ( ( k + 1 ) + ( n − 1 ) − 1 n − 1 ) = ( k + n − 1 n − 1 ) = ( k + n − 1 k ) ( ( n k ) ) = ( k + n − 1 k ) \left(\binom{k+1}{n-1}\right)=\binom{(k+1)+(n-1)-1}{n-1} =\binom{k+n-1}{n-1} =\binom{k+n-1}{k}\\ \left(\binom{n}{k}\right)=\binom{k+n-1}{k} ((n1k+1))=(n1(k+1)+(n1)1)=(n1k+n1)=(kk+n1)((kn))=(kk+n1)

    • 恒等式得证

  • This identity follows from interchanging the stars and bars in the above representation.

Example of counting multisubsets🎈
  • For example, if you have four types of donuts(甜甜圈) ( n = 4 n = 4 n=4) on a menu to choose from and you want three donuts (k = 3), the number of ways to choose the donuts with repetition can be calculated as
  • (  ⁣ ⁣ ( 4 3 )  ⁣ ⁣ ) = ( 4 + 3 − 1 3 ) = ( 6 3 ) = 6 × 5 × 4 3 × 2 × 1 = 20. {\displaystyle \left(\!\!{\binom {4}{3}}\!\!\right)={\binom {4+3-1}{3}}={\binom {6}{3}}={\frac {6\times 5\times 4}{3\times 2\times 1}}=20.} ((34))=(34+31)=(36)=3×2×16×5×4=20.
  • This result can be verified by listing all the 3-multisubsets of the set S = {1,2,3,4}.
  • This is displayed in the following table.
    • The second column lists the donuts you actually chose, (the types of 3 donuts you chose )
    • the third column shows the nonnegative integer solutions [ x 1 , x 2 , x 3 , x 4 ] [x_{1},x_{2},x_{3},x_{4}] [x1,x2,x3,x4] of the equation x 1 + x 2 + x 3 + x 4 = 3 x_{1}+x_{2}+x_{3}+x_{4}=3 x1+x2+x3+x4=3
    • the last column gives the stars and bars representation of the solutions.
  • No.3-multisetEq. solutionStars and bars
    • 假设取得的3个甜甜圈分别属于类型 i 1 , i 2 , i 3 i_1,i_2,i_3 i1,i2,i3,记为{ i 1 , i 2 , i 3 i_1,i_2,i_3 i1,i2,i3}
    • 并且{ i 1 , i 2 , i 3 i_1,i_2,i_3 i1,i2,i3}内部调整顺序,仍然算作同一种情况,为了方便以及避免重复计数,仅展示 ( i 1 ⩽ i 2 ⩽ i 3 ) (i_1\leqslant i_2\leqslant i_3) (i1i2i3)的情况
    • 如此,可以理解为,当前拿的甜甜圈类别号不小于前一次拿的类比号
    • 其中, 1 ∼ 10 1\sim{10} 110是取出的3个甜甜圈中至少有一个类型1的情况
      • 11 ∼ 16 11\sim{16} 1116是取出的甜甜圈不包含类型1但是包含类型2的情况
      • 17 ∼ 19 17\sim{19} 1719是取出的甜甜圈不包含类型1,2,但是包含类型3的情况
      • 20 20 20是取出的甜甜圈不包含类型1,2,3,包含类型4的情况(由于总共就4种,所以这类情况仅有类型4的甜甜圈)
  1. {1,1,1}[3,0,0,0] ★ ★ ★ ∣ ∣ ∣ \bigstar \bigstar \bigstar ||| ★★★∣∣∣

  2. {1,1,2}[2,1,0,0] ★ ★ ∣ ★ ∣ ∣ \bigstar \bigstar |\bigstar || ★★∣∣

  3. {1,1,3}[2,0,1,0] ★ ★ ∣ ∣ ★ ∣ \bigstar \bigstar ||\bigstar | ★★∣∣

  4. {1,1,4}[2,0,0,1] ★ ★ ∣ ∣ ∣ ★ \bigstar \bigstar |||\bigstar ★★∣∣∣

  5. {1,2,2}[1,2,0,0] ★ ∣ ★ ★ ∣ ∣ \bigstar |\bigstar \bigstar || ★★∣∣

  6. {1,2,3}[1,1,1,0] ★ ∣ ★ ∣ ★ ∣ \bigstar |\bigstar |\bigstar |

  7. {1,2,4}[1,1,0,1] ★ ∣ ★ ∣ ∣ ★ \bigstar |\bigstar ||\bigstar ∣∣

  8. {1,3,3}[1,0,2,0] ★ ∣ ∣ ★ ★ ∣ \bigstar ||\bigstar \bigstar | ∣∣★★

  9. {1,3,4}[1,0,1,1] ★ ∣ ∣ ★ ∣ ★ \bigstar ||\bigstar |\bigstar ∣∣

  10. {1,4,4}[1,0,0,2] ★ ∣ ∣ ∣ ★ ★ \bigstar |||\bigstar \bigstar ∣∣∣★★

  11. {2,2,2}[0,3,0,0] ∣ ★ ★ ★ ∣ ∣ |\bigstar \bigstar \bigstar || ★★★∣∣

  12. {2,2,3}[0,2,1,0] ∣ ★ ★ ∣ ★ ∣ |\bigstar \bigstar |\bigstar | ★★

  13. {2,2,4}[0,2,0,1] ∣ ★ ★ ∣ ∣ ★ |\bigstar \bigstar ||\bigstar ★★∣∣

  14. {2,3,3}[0,1,2,0] ∣ ★ ∣ ★ ★ ∣ |\bigstar |\bigstar \bigstar | ★★

  15. {2,3,4}[0,1,1,1] ∣ ★ ∣ ★ ∣ ★ |\bigstar |\bigstar |\bigstar

  16. {2,4,4}[0,1,0,2] ∣ ★ ∣ ∣ ★ ★ |\bigstar ||\bigstar \bigstar ∣∣★★

  17. {3,3,3}[0,0,3,0] ∣ ∣ ★ ★ ★ ∣ ||\bigstar \bigstar \bigstar | ∣∣★★★

  18. {3,3,4}[0,0,2,1] ∣ ∣ ★ ★ ∣ ★ ||\bigstar \bigstar |\bigstar ∣∣★★

  19. {3,4,4}[0,0,1,2] ∣ ∣ ★ ∣ ★ ★ ||\bigstar |\bigstar \bigstar ∣∣★★

  20. {4,4,4}[0,0,0,3] ∣ ∣ ∣ ★ ★ ★ |||\bigstar \bigstar \bigstar ∣∣∣★★★

隔板模型

  • 隔板法是组合数学的方法,用来处理 n n n个无差别的球放进 k k k个不同的盒子的问题。可一般化为求不定方程的解数

  • 隔板法与插空法的原理一样。

refs
隔板问题示例
  • 现在有 10 10 10个球,要放进 3 3 3个盒子里,每个盒子至少一个球
  • 利用隔板法求解,需要 2 2 2个板子来把 10 10 10个球被隔开成 3 3 3个部分
    • ●|●|●●●●●●●●、●|●●|●●●●●●●、…
  • 10 10 10个球放进 3 3 3个盒子(空间)的方法总数为 ( 10 − 1 3 − 1 ) = ( 9 2 ) = 36 {\binom {10-1}{3-1}}={\binom {9}{2}}=36 (31101)=(29)=36
无空盒子隔板模型
  • n n n个球放进 k k k个盒子的方法总数为 ( n − 1 k − 1 ) {\binom {n-1}{k-1}} (k1n1)
    • n个球内部可供插板的位置有 n − 1 n-1 n1个(之所以是内部插板,是因为每个插板两侧都至少有一个球)
      • 例如,2个球(用$表示球,用|表示隔板,可能的插板情况:|$|$|,三条 |对应3种可能)
    • 将n个球放入 k k k个盒子,相当于从所有可能的隔板 n − 1 n-1 n1位置选出 k − 1 k-1 k1个(会划分出 k k k个部分,对应放到k个盒子种)
丢番图方程及其解的个数
  • 隔板模型问题等价于求 ∑ i = 1 k x i = n \sum_{i=1}^{k}x_i=n i=1kxi=n的可行解数,其中 x i ∈ N + x_i\in{\mathbb{N^+}} xiN+
  • 解的个数为 ( n − 1 k − 1 ) \binom{n-1}{k-1} (k1n1)
空盒子推广🎈
  • 现在有 10 10 10个球,要放进 3 3 3个盒子里,并允许空盒子。
    • 无空盒的情况更加简单,考虑将问题转换为无空盒的问题,间接计算允许空盒的情况
    • 从所有无空盒中各取一个球,使得所有仅有一个球的盒子变成空盒,从无空盒问题转换为允许空盒问题
  • 问题转化为:现有10+3个球,放进3个盒子里,每个盒子至少一个球,然后再从3个盒子里各取出1个球
  • 考虑 10 + 3 {\displaystyle 10+3} 10+3个球的情况:
    • ●|●|●●●●●●●●●●●、●|●●|●●●●●●●●●●、●|●●●|●●●●●●●●●、●|●●●●|●●●●●●●●、●|●●●●●|●●●●●●●、…
    • 每个盒子的球都被拿走一个,得到一种情况,如此类推:
      • ||●●●●●●●●●●、|●|●●●●●●●●●、|●●|●●●●●●●●、|●●●|●●●●●●●、|●●●●|●●●●●●、…
  • n n n个球放进 k k k个盒子的方法总数(允许空盒子),等同于 n + k n+k n+k个球放进 k k k个盒子的方法总数(不允许空盒子),即 ( n + k − 1 k − 1 ) {\binom {n+k-1}{k-1}} (k1n+k1)

stars and bars

  • In the context of combinatorial mathematics, stars and bars (also called “sticks and stones”,“balls and bars”, and “dots and dividers”) is a graphical aid for deriving certain combinatorial theorems.
  • It was popularized by William Feller in his classic book on probability. It can be used to solve many simple counting problems, such as how many ways there are to put n indistinguishable balls into k distinguishable bins.
Statements of theorems🎈
  • The stars and bars method is often introduced specifically to prove the following two theorems of elementary combinatorics(组合数学) concerning the number of solutions to an equation.
Theorem one🎈
  • For any pair of positive integers n and k, the number of k-tuples of positive integers whose sum is n is equal to the number of (k − 1)-element subsets of a set with n − 1 elements.

  • For example, if n = 10 and k = 4, the theorem gives the number of solutions to ∑ i = 1 4 x i = 10 \sum_{i=1}^{4}x_i = 10 i=14xi=10 (with x i ∈ N + x_i\in{\mathbb{N^+}} xiN+ ) as the binomial coefficient

  • ( n − 1 k − 1 ) = ( 10 − 1 4 − 1 ) = ( 9 3 ) = 84. {\displaystyle {\binom {n-1}{k-1}}={\binom {10-1}{4-1}}={\binom {9}{3}}=84.} (k1n1)=(41101)=(39)=84.

  • This corresponds to compositions of an integer.

Theorem two🎈
  • For any pair of positive integers n and k, the number of k-tuples of non-negative integers whose sum is n is equal to the number of multisets(多重集) of cardinality n (the number of elements in a set or other grouping, as a property of that grouping) taken from a set of size k, or equivalently, the number of multisets of cardinality k − 1 taken from a set of size n + 1.
  • 对于任意一对正整数n和k
    • 元素之和为n的非负整数k元组的数量等于
    • 从大小为k的集合中取出基数为n的多重集的数量,或者等价地说,等于从大小为n+1的集合中取出基数为k-1的多重集的数量。
  • For example, if n = 10 and k = 4, the theorem gives the number of solutions to ∑ i = 1 4 x i = 10 \sum_{i=1}^{4}x_i = 10 i=14xi=10 (with x i ∈ N x_i\in{\mathbb{N}} xiN ) as:
  • (  ⁣ ⁣ ( k n )  ⁣ ⁣ ) = ( k + n − 1 n ) = ( 13 10 ) = 286 {\displaystyle \left(\!\!{k \choose n}\!\!\right)={k+n-1 \choose n}={\binom {13}{10}}=286} ((nk))=(nk+n1)=(1013)=286
  • (  ⁣ ⁣ ( n + 1 k − 1 )  ⁣ ⁣ ) = ( n + 1 + k − 1 − 1 k − 1 ) = ( 13 3 ) = 286 {\displaystyle \left(\!\!{n+1 \choose k-1}\!\!\right)={n+1+k-1-1 \choose k-1}={\binom {13}{3}}=286} ((k1n+1))=(k1n+1+k11)=(313)=286
  • ( n + k − 1 k − 1 ) = ( 10 + 4 − 1 4 − 1 ) = ( 13 3 ) = 286 {\displaystyle {\binom {n+k-1}{k-1}}={\binom {10+4-1}{4-1}}={\binom {13}{3}}=286} (k1n+k1)=(4110+41)=(313)=286
  • This corresponds to weak compositions of an integer.

多项式定理展开式的项数

  • 允许空盒的隔板问题的解等价于求 x 1 + x 2 + . . . + x k = n x_{1}+x_{2}+...+x_{k}=n x1+x2+...+xk=n的可行解数,其中 x 1 , x 2 , . . . , x k x_{1},x_{2},...,x_{k} x1,x2,...,xk非负整数
  • ( ( k n ) ) \left(\binom{k}{n}\right) ((nk))= ( n + k − 1 k − 1 ) {\binom {n+k-1}{k-1}} (k1n+k1)= ( n + k − 1 n ) {\binom {n+k-1}{n}} (nn+k1)也是 ( a 1 + a 2 + . . . + a k ) n (a_{1}+a_{2}+...+a_{k})^{n} (a1+a2+...+ak)n展开式的项数 ∑ n 1 + n 2 + . . . + n k = n 1 \displaystyle\sum _{{n_{1}+n_{2}+...+n_{k}=n}}1 n1+n2+...+nk=n1
  • 注意到这个其实就是K-MC问题
  • 前面的章节中介绍的 k , n k,n k,n的和含义恰好相反,因此这里要注意一下,它们是同一种模型
posted @   xuchaoxin1375  阅读(28)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示