combination-and-permutation
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Combination and Permutation computation 组合和排列计算

1. Combination 组合

Every combination has same probability.
每一种组合都有相同的概率

execute combination(3) 10000 times, we got:
执行了10000次combination(3),结果如下:
'[2,3]' => 1469,
'[1,2]' => 1370,
'[1,2,3]' => 1447,
'[3]' => 1400,
'[1,3]' => 1413,
'[1]' => 1471,
'[2]' => 1430

2. Permutation 排列

Obviously, permutations and combinations are different, and permutations with different numbers have different probabilities
很明显,排列跟组合不同,不同数量数字的排列具有不同的概率

execute permutation(3) 10000 times, we got:
执行了10000次permutation(3),结果如下:
'[3]' => 1417,
'[2,1,3]' => 264,
'[2,3]' => 671,
'[3,1,2]' => 267,
'[3,1]' => 708,
'[1,3]' => 698,
'[2]' => 1412,
'[2,3,1]' => 230,
'[3,2,1]' => 226,
'[1,2,3]' => 260,
'[3,2]' => 746,
'[1,2]' => 750,
'[1,3,2]' => 225,
'[1]' => 1414,
'[2,1]' => 727

Package Sidebar

Install

npm i combination-and-permutation

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

13.9 kB

Total Files

22

Last publish

Collaborators

  • zyballbj