fundamentals\Counting

The Rule of Sum: If a first task can be performed in m ways, while a second task can be performed in n ways, and the two tasks cannot be performed simultaneously, then performing either task can be accomplished in any one of m+n ways.

The Rule of Product: If a procedure can be broken down into first and second stages, and if there are m possible outcomes for the first stage and if, for each of these outcomes, there are n possible outcomes for the second stage, then the total procedure can be carried out, in the designated order, in mn ways.        

Permutations:

If there are n distinct objects and r is an integer, with 1<=r<=n, then by the rule of product, the number of permutations of size r for the n objects is

P(n, r)       = n × (n-1) × (n-2) ×× (n – r + 1)

                  = n × (n-1) × (n-2) ×× (n – r + 1) × (n-r)(n-r-1)…(3)(2)(1)/ (n-r)(n-r-1)…(3)(2)(1)

                  = n!/(n-r)!

Permutations with Repetition:

If there are n objects with n1 indistinguishable objects of a first type, n2 indistinguishable objects of a second type,…,and nr indistinguishable objects of an rth type, where n1+n2+…+nr = n, then there are n!/n1! N2! N3! … nr! (linear) arrangements of the given n objects.

Permutations in circular:

Consequently, there are n!/n = (n-1)! Arrangements of n objects around the circular.

Binomial:

If we start with n distinct objects, each selection, or combination, of r of these objects, with no reference to order, corresponds to r! permutations of size r from the n objects. Thus the number of combinations of size r from a collection of size n is

C(n, r) = P(n, r)/ r! = n!/ r! (n-r)!; 0<=r<=n

Combinations with Repetition:

When we wish to select, with repetition, r of n distinct objects, we find that we can considering all arrangements of r x’s and n-1 |’s and that their number is (n + r - 1)!/ r! (n-1)! = (n + r – 1, r). Consequently, the number of combinations of n objects taken r at a time, with repetition, is C(n + r -1, r).

Equivalence:

  1. The number of Integer solutions of the equation X1 + x2 + x3 +…+ xn = r1
  2. The number of selection, with repletion, of size r from a collection of size n.
  3. The number of ways r identical objects can be distributed among n distinct containers.

好的,我们举个栗子:

昨儿个玩打架游戏,头都被锤飞了。

这是自然语言,我们能不能建模成数学语言? 用Counting数数这句话里的可计数地方。

谁玩游戏?我。玩什么游戏?打架游戏。谁打谁?他打我,我也打他。他是谁?其他人。打赢了么?头都被锤飞了。一直都输?赢了3把输了10把。

Sum原则:○我和其他人玩打架游戏 + 打架结果输了 = 昨儿个;○赢了3把 + 输了12把 = 打了15把;

Product原则:○我1和 {其他人2,其他人3,其他人4} 打架 有1 × 3 种打法;{其他人2,其他人3,其他人4}和 我1 打架有 3 × 1 种打法;

Permutations原则:○{我1,其他人2,其他人3,其他人4} 取两个人出来打架,并区分我打你和你打我,有4!/(4-2)! = 12种打法;

比如登记系统,因为区分客户找业务员,与业务员找客户两种不同的客户来源,所以我们有单独的登记表,然后流程表引用登记表,流程不关心客户找业务员还是业务员找客户。简而言之,登记业务中{客户,业务员}是排列算法,流程业务中{客户,业务员}是组合算法。

Permutations with Repetition原则:○{我1,其他人2,其他人3,其他人4}排队,有4!/3!= 4 种排列;

Permutations in circular原则:○{我1,其他人2,其他人3,其他人4}排成一圈,有4!/4 = 6 种排法;

Combinations原则:○{我1,其他人2,其他人3,其他人4} 取两个人出来打架,有 4!/ 2! (4-2)! = 6 种方法;

Combinations with Repetition原则:○{我,其他人} 从中取出两个人 ,有C(2 + 2 – 1, 2) = 3!/2!=3 种方法;减去其中 {我1,我1}的不合理组合 = 3 - 1 = 2 种打法,分别为:{我,其他人}打架、 {其他人, 其他人}打架;

复杂点的:一共打了10场,分别是和张三打了两回共6次,和李四打了两回共3次,有多少种打法;x1+x2=6(x1,x2>0)<=>x1+x2=4(x1,x2>=0)为C(2+4-1,4)=5种。y1+y2=3(y1,y2>0)<=>y1+y2=1(y1,y2>=0)=C(2+1-1,1)=2种,一共有5+2=7种打法;

我们知道Favior combination over Inherited,那么什么是组合?

其他的东西未完待续……

猜你喜欢

转载自blog.csdn.net/u012296499/article/details/81351180