# 排列

排列是将一个集合中的元素重新排序，既不丢失、也不增加或改变任何元素<sup>[1](https://xlinux.nist.gov/dads/HTML/permutation.html)</sup>。在数学中，这个词有两个密切相关的含义：将 n 个不同元素按某种顺序作出的安排，以及一个集合到自身的双射映射，后者也称为替换<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup>。n 个不同元素的排列数为 n!，即 n 的阶乘<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup><sup> • </sup><sup>[1](https://xlinux.nist.gov/dads/HTML/permutation.html)</sup>。

| 关键事实 | 详情 |
|---|---|
| 计数 | n 个可区分元素的排列共有 n! 个<sup>[1](https://xlinux.nist.gov/dads/HTML/permutation.html)</sup> |
| 代数形式 | 排列是一个集合到自身的一一映射；X 的所有排列构成对称群 S(X)，当 \|X\| = n 时记作 S_n<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup> |
| 奇偶性 | 每个排列都是若干对换的乘积；因子个数的奇偶性与分解方式无关，因此有 n!/2 个偶排列和 n!/2 个奇排列<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup> |
| 错排 | 错排是没有不动点的排列；其数目为 \( d(n) = n!\sum_{j=0}^{n}(-1)^j/j! = \lfloor (n!+\mathrm{e}-2)/\mathrm{e} \rfloor \)<sup>[4](https://dlmf.nist.gov/26.13)</sup> |
| 逆序 | 若 i < j 而 π(i) > π(j)，则称对 \{π(i), π(j)\} 为一个逆序；逆序数等于表示该排列所需相邻对换的最少个数<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup><sup> • </sup><sup>[4](https://dlmf.nist.gov/26.13)</sup> |
| 历史 | 拉格朗日于 1770 年研究了根的排列；柯西 1844 年的工作引入了循环记法，使排列理论成为一门独立的学科<sup>[5](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)</sup> |
| 统计学 | 当可交换性假设成立时，置换检验给出精确的 p 值<sup>[6](https://digitalcommons.wayne.edu/jmasm/vol1/iss2/34/)</sup> |

## 定义与记法

作为一种安排，n 个元素的排列是一个长度为 n 的有限序列，其中所有元素互不相同，即无重复的排列<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup>。在大多数情形下，元素取自 \( \mathbf{Z}_n = \{1, \dots, n\} \)，而排列 \( \overline{\pi} = (\pi(1) \dots \pi(n)) \) 由 \( \mathbf{Z}_n \) 到自身的双射 \( \pi \) 给出。<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup>

作为一种映射，排列是一个集合到自身的一一映射，这一术语主要用于有限集<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。对于 \( X = \{1, \dots, n\} \)，它用双行记法写作

\[ \gamma = \begin{pmatrix} 1 & \dots & n \\ i_1 & \dots & i_n \end{pmatrix}, \]

意思是 \( \gamma(k) = i_k \)<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。DLMF 对任意 \( \sigma \in \mathfrak{S}_n \)（即 \{1, 2, ..., n\} 的排列之集）给出了等价的 \( 2 \times n \) 矩阵表示<sup>[4](https://dlmf.nist.gov/26.13)</sup>。两个排列的乘积是它们相继作用的结果，\( \alpha\beta(x) = \alpha(\beta(x)) \)<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。

## 循环、对换与奇偶性

**循环记法。** 每个排列都分解为互不相交的循环：即形如 \( \{x, \gamma(x), \dots, \gamma^{l-1}(x)\} \) 的子集，排列在每个子集上循环作用<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。在循环记法中，每个循环的元素放在括号内，使 \( \sigma(j) \) 紧跟在 j 之后；长度为一的循环即不动点，通常省略不写<sup>[4](https://dlmf.nist.gov/26.13)</sup>。例如，将 1 至 8 分别映射到 3、5、2、4、7、8、1、6 的排列，用循环记法写作 \( (1,3,2,5,7)(6,8) \)<sup>[4](https://dlmf.nist.gov/26.13)</sup>。一个排列的阶，即它所生成的循环群的阶，等于其互不相交循环长度的最小公倍数<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。

对换是恰好移动两个元素的排列，等价地说，是由一个长度为二的循环构成的排列；\( S_n \) 中含有 \( n(n-1)/2 \) 个对换<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup><sup> • </sup><sup>[4](https://dlmf.nist.gov/26.13)</sup>。每个排列都是若干对换的乘积，而循环型为 \( (a_1, a_2, \dots, a_n) \) 的排列可以写成 \( a_2 + 2a_3 + \cdots + (n-1)a_n = n - (a_1 + a_2 + \cdots + a_n) \) 个对换的乘积，且不能更少<sup>[4](https://dlmf.nist.gov/26.13)</sup>。

**奇偶性。** 对给定的排列，任意分解为对换的因子个数的奇偶性与分解方法无关<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。排列依此奇偶性分为偶排列或奇排列，其符号在偶时为 +，在奇时为 −<sup>[4](https://dlmf.nist.gov/26.13)</sup>。这一奇偶性与该排列单行形式中逆序数的奇偶性一致<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。偶排列构成对称群的一个正规子群，即交错群 \( A_n \)，而 \( S_n \) 中含有 \( n!/2 \) 个偶排列，奇排列的数目与之相同<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。

**相邻对换。** 每个对换都是若干相邻对换的乘积，相邻对换即两个连续整数的对换：若 j < k，则 (j, k) 是 \( 2k - 2j - 1 \) 个相邻对换的乘积<sup>[4](https://dlmf.nist.gov/26.13)</sup>。逆序数 \( \mathrm{inv}(\sigma) \) 是表示 \( \sigma \) 所需相邻对换的最少个数；对上文的例子，它等于 11<sup>[4](https://dlmf.nist.gov/26.13)</sup>。

## 计数结果

n 个元素的排列数为 \( n! \)<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup>。若 \( a_r \) 是 n 个元素恰有 r 个逆序的排列数，则生成函数为

\[ \sum_{r=0}^{\binom{n}{2}} a_r x^r = \frac{(1-x)\dots(1-x^n)}{(1-x)^n}. \]

若 \( b_n \) 是各项交替上升和下降的排列数，则 \( \sum_{n=0}^{\infty} b_n x^n/n! = \tan x + \sec x \)<sup>[2](https://encyclopediaofmath.org/wiki/Permutation)</sup>。第一类斯特林循环数 \( \left[\begin{smallmatrix} n \\ k \end{smallmatrix}\right] \) 计数 \{1, ..., n\} 中恰有 k 个循环的排列<sup>[4](https://dlmf.nist.gov/26.13)</sup>。

错排是没有不动点的排列，错排数 \( d(n) \) 计数这类排列<sup>[4](https://dlmf.nist.gov/26.13)</sup>。在算法意义上，排序是将项目按某种顺序安排的排列，而错排则是没有任何项目处于其原始位置的排列<sup>[1](https://xlinux.nist.gov/dads/HTML/permutation.html)</sup>。

## 置换群

一个集合 X 的所有排列在复合运算下构成一个群，即对称群；对称群的任何子群都称为置换群<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。由凯莱定理，任何抽象群都可以表示为适当集合上的置换群<sup>[7](https://encyclopediaofmath.org/wiki/Permutation_group)</sup>。置换群在离散数学中有诸多应用，包括布尔函数与有限自动机的分类、纠错码理论，以及复杂有机化合物异构体的计数<sup>[7](https://encyclopediaofmath.org/wiki/Permutation_group)</sup>。

**历史发展。** 排列最初于 18 世纪在组合学中产生<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。拉格朗日 1770 年关于方程代数解的论文考察了根的表达式在根的排列下只取少数不同值的情形，但他从未对自己的排列作复合，因此在某种意义上从未讨论过群<sup>[5](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)</sup>。鲁菲尼在其 1799 年关于五次方程的工作中引入了置换群<sup>[5](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)</sup>。柯西关于此主题的第一篇论文于 1815 年发表，而他 1844 年的重要工作将排列理论建立为一门独立的学科，引入了排列的幂、排列的阶、循环记法，以及用以指称群的术语“共轭替换系”<sup>[5](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)</sup>。将排列表示为循环乘积的想法尤其应归功于柯西<sup>[3](https://encyclopediaofmath.org/wiki/Decrement)</sup>。1831 年，伽罗瓦成为第一个真正领悟到方程能否代数求解取决于其关联置换群的结构的人，而凯莱后来证明了任何有限群都可实现为置换群<sup>[5](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)</sup>。

## 线性代数中的排列

置换矩阵的每一行和每一列恰有一个 1，其余位置为零；其各行是 \( e_{\sigma(1)}^T, \dots, e_{\sigma(n)}^T \)，其中 \( \sigma \) 是 \( 1, \dots, n \) 的某个重排<sup>[8](https://ee.iitm.ac.in/~uday/notes/linalg/lse.html)</sup>。乘以置换矩阵即执行行交换<sup>[9](https://www.ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/pages/ax-b-and-the-four-subspaces/transposes-permutations-vector-spaces/)</sup>。在带行主元的高斯消元中，结果可表示为 \( PA = LU \)，其中 P 是置换矩阵，L 是下三角矩阵，U 是上三角矩阵<sup>[10](https://sites.pitt.edu/~trenchea/MATH1080/MATH1080.pdf)</sup>。置换矩阵的乘积仍是置换矩阵，不过置换矩阵一般不可交换<sup>[11](https://nikolaimatni.github.io/ese-2030/linsys-perms)</sup>。

## 排列的生成与洗牌

有若干成熟的算法可以枚举一个集合的全部排列：朴素递归法、Heap 算法、字典序生成法，以及 Steinhaus–Johnson–Trotter 算法<sup>[12](https://github.com/laekov/pperm)</sup>。任何枚举全部排列的方法都面临相同的阶乘级输出规模，因此它们之间的选择影响的是常数因子和内存占用，而非渐近的输出代价<sup>[13](https://codemia.io/knowledge-hub/path/big-o_analysis_of_permutation_algorithm)</sup>。

若要随机选取一个排列，Fisher-Yates 洗牌算法可随机置换元素<sup>[1](https://xlinux.nist.gov/dads/HTML/permutation.html)</sup>。R. A. 费希尔与 F. 耶茨 在他们 1938 年的《统计表》中描述了该方法，而 理查德·杜斯滕菲尔德的随机化计算机版本以算法 235“随机排列”为题，发表于 1964 年 7 月的《ACM 通讯》7(7):420<sup>[14](https://xlinux.nist.gov/dads/HTML/fisherYatesShuffle.html)</sup>。理想的随机洗牌是一种产生任何排列的机会完全相同的排列算法<sup>[15](https://xlinux.nist.gov/dads/HTML/idealRandomShuffle.html)</sup>。即使元素个数相当少，排列的总数也远远大于大多数伪随机数发生器的周期，这意味着大多数排列永远不会由这样的发生器产生<sup>[14](https://xlinux.nist.gov/dads/HTML/fisherYatesShuffle.html)</sup>。

## 统计学中的置换检验

在统计学中，置换检验通过在数据的置换版本上重新计算检验统计量，并将观测值与这一经验零分布相比较，来评估检验统计量<sup>[16](https://pmc.ncbi.nlm.nih.gov/articles/PMC10066020/)</sup>。置换检验在多种实际检验情形中给出精确的 p 值，但它们依赖于可交换性假设：在假设之下，观测值的联合分布在标号置换下不变<sup>[6](https://digitalcommons.wayne.edu/jmasm/vol1/iss2/34/)</sup>。当可交换性满足时，置换检验精确地控制第一类错误<sup>[17](https://www.sciencedirect.com/science/article/pii/S0047259X25000168)</sup>。当穷举枚举不切实际时，可以用排列的随机样本而非全部可能的排列来近似 p 值<sup>[17](https://www.sciencedirect.com/science/article/pii/S0047259X25000168)</sup>。软件实现支持三种置换类型：'samples' 用于配对检验，如 威尔科克森符号秩检验和配对 t 检验；'pairings' 用于关联检验，使用 斯皮尔曼 ρ 和皮尔逊 r 等统计量；'independent' 用于 曼–惠特尼 U 检验和独立样本 t 检验等<sup>[18](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.permutation_test.html)</sup>。

统计文献对“置换检验”和“随机化检验”这两个术语的使用并不一致；若干作者主张这两个术语应指两个不同的类别，因为置换检验的推理基于排列的群结构，而随机化检验的推理则不然<sup>[19](https://onlinelibrary.wiley.com/doi/full/10.1111/insr.12431)</sup>。

## References

1. [Paul E. Black, "permutation", in Dictionary of Algorithms and Data Structures, NIST](https://xlinux.nist.gov/dads/HTML/permutation.html)
2. ["Permutation", Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Permutation)
3. ["Permutation of a set", Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Decrement)
4. [DLMF §26.13 Permutations: Cycle Notation, NIST Digital Library of Mathematical Functions](https://dlmf.nist.gov/26.13)
5. [J. J. O'Connor and E. F. Robertson, "The development of group theory", MacTutor History of Mathematics](https://mathshistory.st-andrews.ac.uk/HistTopics/Development_group_theory/)
6. [Phillip I. Good, "Extensions of the Concept of Exchangeability and Their Applications", Journal of Modern Applied Statistical Methods](https://digitalcommons.wayne.edu/jmasm/vol1/iss2/34/)
7. ["Permutation group", Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Permutation_group)
8. [Linear system of equations lecture notes, EE5120, IIT Madras](https://ee.iitm.ac.in/~uday/notes/linalg/lse.html)
9. [Transposes, Permutations, Vector Spaces, MIT OpenCourseWare 18.06SC](https://www.ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/pages/ax-b-and-the-four-subspaces/transposes-permutations-vector-spaces/)
10. [Numerical Linear Algebra, University of Pittsburgh MATH1080](https://sites.pitt.edu/~trenchea/MATH1080/MATH1080.pdf)
11. [The Permuted LU-Factorization, ESE 2030 lecture notes, University of Pennsylvania](https://nikolaimatni.github.io/ese-2030/linsys-perms)
12. [laekov/pperm: Parallel implementations of permutation generation algorithms, GitHub](https://github.com/laekov/pperm)
13. [Big-O analysis of permutation algorithm, Codemia](https://codemia.io/knowledge-hub/path/big-o_analysis_of_permutation_algorithm)
14. [Paul E. Black, "Fisher-Yates shuffle", in Dictionary of Algorithms and Data Structures, NIST](https://xlinux.nist.gov/dads/HTML/fisherYatesShuffle.html)
15. [Paul E. Black, "ideal random shuffle", in Dictionary of Algorithms and Data Structures, NIST](https://xlinux.nist.gov/dads/HTML/idealRandomShuffle.html)
16. [Permutation tests for experimental data, PMC](https://pmc.ncbi.nlm.nih.gov/articles/PMC10066020/)
17. [A review of multivariate permutation tests: Findings and trends, Journal of Multivariate Analysis](https://www.sciencedirect.com/science/article/pii/S0047259X25000168)
18. [scipy.stats.permutation_test, SciPy v1.18.0 Manual](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.permutation_test.html)
19. [Hemerik (2021), "Another Look at the Lady Tasting Tea and Differences Between Permutation Tests and Randomisation Tests", International Statistical Review](https://onlinelibrary.wiley.com/doi/full/10.1111/insr.12431)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 逻辑与离散数学 › General discrete mathematics and discrete structures › Combinatorics › Enumerative combinatorics

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/permutation

English original: https://www.edgepedia.org/permutation
