# 幂变换

幂变换是一类参数化数据变换，由变量的幂次构造而成，用以使分布更接近正态、方差更趋恒定或关系更趋线性。Box–Cox 变换是一种广泛使用的幂变换，定义为：当 \( \lambda \neq 0 \) 时，\( y(\lambda) = (y^{\lambda} - 1)/\lambda \)；当 \( \lambda = 0 \) 时，为 \( \log y \)。其中单一参数 \( \lambda \) 由数据估计得出<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup><sup> • </sup><sup>[2](https://proceedings.mlr.press/v300/xu26d.html)</sup>。缩放幂族可追溯至约翰·W·图基（John W. Tukey，1957），并由乔治·E·P·博克斯（George E. P. Box）与大卫·R·考克斯（David R. Cox）在 1964 年发表于《皇家统计学会杂志，B 辑》的论文中，于变换线性模型的语境下提出<sup>[3](https://www.sciencedirect.com/science/article/abs/pii/S0304407623000568)</sup><sup> • </sup><sup>[4](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义 | 当 \( \lambda \neq 0 \) 时，\( y(\lambda) = (y^{\lambda} - 1)/\lambda \)；当 \( \lambda = 0 \) 时，为 \( \log y \)<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> |
| 标准 λ 值 | λ = 1：不变换；λ = 1/2：平方根；λ = 0：对数；λ = −1：倒数<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> |
| 估计 | λ 由最大似然法选取；轮廓对数似然 \( L_{\max}(\lambda) = -(n/2)\log\{R(\lambda)/(n-p)\} \)<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup> |
| 负值数据 | Yeo–Johnson（2000）扩展在四种情形下使用同一 λ 处理负值<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup> |
| 搜索范围 | 软件默认一般扫描 −3 到 3 的幂次<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup> |
| 关键告诫 | 幂变换并不保证正态性，且可能依位置、尺度和离群值而降低正态性<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup> |

## 定义与数学形式

博克斯与考克斯（1964）以正态理论线性模型为动机提出该变换：他们假定响应变量独立地服从正态分布，具有恒定方差，且期望由关于参数 θ 线性的模型所指定，随后寻求一种变换以同时实现正态性、同方差性和线性<sup>[4](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)</sup>。

**λ = 0 处的对数极限。** 当 λ = 0 时，公式 \( (y^{\lambda} - 1)/\lambda \) 成为不定式 0/0，必须重新改写<sup>[8](https://onlinestatbook.com/2/transformations/transformations.pdf)</sup>。当 \( \lambda \to 0 \) 时应用洛必达法则可知，所得为对数变换，因此该族避开了简单幂变换 \( y^{\lambda} \) 在零点处的不连续性<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>。《数学百科全书》给出了相同的分段定义，其中 λ 由最大似然法估计<sup>[9](https://encyclopediaofmath.org/wiki/Box%E2%80%93Cox_transformation)</sup>。

**平移参数。** 博克斯与考克斯最初在变换中包含了一个平移参数，但在其形式分析中将其设为 0；Yeo 与 Johnson（2000）则既未包含平移参数，也未包含尺度参数<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。由于 Box–Cox 要求观测值为正，加上一个常数便产生了平移幂变换<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>。

## 估计变换参数

**最大似然与轮廓似然。** 轮廓对数似然是在 \( \beta(\lambda) \) 和 \( \sigma^2(\lambda) \) 上部分最大化后得到的，为 \( L_{\max}(\lambda) = -(n/2)\log\{R(\lambda)/(n-p)\} \)，其中 \( R(\lambda) \) 为残差平方和；估计 λ 需要对 \( y(\lambda) \) 的尺度变化作雅可比调整<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。NIST 将正态性版本表述为 \( f(x,\lambda) = -\frac{n}{2}\ln\left[\sum_{i=1}^{n}\frac{(x_i(\lambda)-\bar{x}(\lambda))^2}{n}\right] + (\lambda-1)\sum_{i=1}^{n}\ln(x_i) \)，通过最大化以求最优 λ<sup>[10](https://www.itl.nist.gov/div898/handbook/pmc/section5/pmc52.htm)</sup>。

**置信区间。** 博克斯与考克斯建议使用似然比检验，其中 \( T_{LR} = 2\{L_{\max}(\hat{\lambda}) - L_{\max}(\lambda_0)\} = n\log\{R(\lambda_0)/R(\hat{\lambda})\} \)；λ 的 100(1−α)% 置信区间由那些在 α 水平下不显著的 \( \lambda_0 \) 值构成<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。NIST 由满足 \( f(x,\lambda) \geq f(x,\hat{\lambda}) - 0.5\,\chi^2_{1-\alpha,1} \) 的 λ 值构成置信集<sup>[10](https://www.itl.nist.gov/div898/handbook/pmc/section5/pmc52.htm)</sup>，SciPy 实现同一准则，即 \( l(\hat{\lambda}) - l(\lambda) < \tfrac{1}{2}\chi^2(1-\alpha,1) \)<sup>[11](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.boxcox.html)</sup>。R 的 car 包则报告 95% 的 Wald 区间，按估计值加减 1.96 倍标准误计算<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup>。

**取近似值为便利的幂次。** 实践中，估计出的幂次会被取为近似值，以得到简单的变换：λ ≈ 0.5 提示平方根，λ 接近零提示自然对数<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup>。博克斯与考克斯强调，选择 λ 部分依据数据，部分依据简洁性与解释便利性的考量<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。

**Yeo–Johnson 扩展。** Yeo 与 Johnson（2000）将 Box–Cox 推广至可正可负的观测值，两者使用同一 λ，并依参数与响应值的不同而需要四种情形<sup>[5](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)</sup>。在零点附近，两族表现不同：对于小的正值，Box–Cox 产生的变化远大于 Yeo–Johnson<sup>[12](https://www.stat.umn.edu/arc/yjpower.pdf)</sup>。car 包的 bcnPower 族（Hawkins 与 Weisberg，2017）为少量非正值提供了另一条途径，对 \( z = 0.5(y + (y^2 + \gamma^2)^{1/2}) \) 应用 Box–Cox，其中 γ 限制在 [0.1, max(y)]，λ 限制在 [−3, 3]；γ 的区间一般非常宽<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup>。

## 为何有效：方差稳定、偏度与正态性

该变换的提出旨在实现三个目标：正态性、同方差性和线性<sup>[4](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)</sup>。参数 λ 控制变换的形状；当 λ ≠ 1 时映射为非线性，会改变分布，对左偏和右偏数据的影响不同<sup>[2](https://proceedings.mlr.press/v300/xu26d.html)</sup>。后来的不变变体在形状参数 λ 之外加入了平移参数 \( x_0 \) 和尺度参数 s<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。

## 用数字说话

在 NIST 的算例中，对数似然在 λ = 0.3（保留两位数字为 0.28）处达到峰值，因此最优点位于对数变换与恒等变换之间<sup>[10](https://www.itl.nist.gov/div898/handbook/pmc/section5/pmc52.htm)</sup>。Feature-engine 的偏度示例报告，原始偏态数据的变异系数高于 1（100%），平方根变换后约为 31%，而使用较低指数的幂变换后为 0.05%<sup>[13](https://feature-engine.trainindata.com/en/latest/user_guide/transformation/PowerTransformer.html)</sup>。软件默认一般在 −3 到 3 的范围内扫描幂次<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup>，SAS 的 PROC TRANSREG 默认按 LAMBDA=−3 TO 3 BY 0.25 搜索<sup>[14](https://go.documentation.sas.com/api/docsets/statug/v_023/content/statug_transreg_details02.htm)</sup>。

## 与其他变换的比较

平方根变换对数值的压缩程度比对数变换温和，用于方差大致与均值成比例的计数数据，且无需修改即可处理零值；倒数变换的压缩作用更强，适用于偏斜严重的比率和率，但会颠倒数值的顺序<sup>[15](https://casrai.org/guides/log-and-other-data-transformations)</sup>。对数变换可纠正右偏并能稳定方差，但两种效果都不保证正态性<sup>[15](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

针对零值的 log(x+1) 变通并不中性：所加常数是任意的，会扭曲小值处的变换。反双曲正弦（asinh）变换是一种日益常用的替代方案，对大值的行为与对数几乎相同，但在零点有定义，对负值也无需任意平移<sup>[15](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

相较于非参数选项，scikit-learn 的 QuantileTransformer 在拥有数千个训练样本时可将任意分布强制转为高斯分布，但作为非参数方法较难解释；在小数据集上（少于几百个点）容易过拟合，此时推荐使用幂变换<sup>[16](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)</sup>。

## 在回归、预测与机器学习中的应用

**解释系数。** 在对数-线性模型中，预测变量上的系数 b 意味着该变量每增加一个单位，结果伴随 \( (e^b - 1) \times 100\% \) 的变化，这是乘性效应而非原始单位下的加性效应；在对数-对数模型中，系数即为弹性<sup>[15](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

**一场仍在进行的统计学争论。** Bickel 与 Doksum（1981）表明，在响应为 \( y(\lambda) \) 的回归模型中，当变换参数确定得不好时，所估计的线性模型参数的变异性可能大大增加。博克斯与考克斯的回应是将 λ 视为部分基于解释性理由而非纯粹由数据选定<sup>[1](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)</sup>。

**软件。** SciPy 的 boxcox 计算 \( y = (x^{\lambda}-1)/\lambda \)，要求输入为正（x < 0 时返回 nan，λ < 0 且 x = 0 时返回 −inf），未提供 λ 时求最大似然 λ<sup>[11](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.boxcox.html)</sup>。scikit-learn 的 PowerTransformer 同时支持 Box–Cox 和 Yeo–Johnson，通过最大似然估计使方差稳定并最小化偏度的参数；Box–Cox 要求数据严格为正，而 Yeo–Johnson 接受两种符号<sup>[17](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)</sup>。car 包的 powerTransform 选择朝向正态性、线性或恒定方差的变换<sup>[6](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)</sup>，SAS 的 PROC TRANSREG 则打印最优幂次、置信区间以及用户列表中的一个便利幂次<sup>[14](https://go.documentation.sas.com/api/docsets/statug/v_023/content/statug_transreg_details02.htm)</sup>。

**预测。** Box–Cox 预测通过以下方式反变换：若 λ = 0 则 \( y_t = \exp(w_t) \)，否则为 \( \mathrm{sign}(\lambda w_t + 1)|\lambda w_t + 1|^{1/\lambda} \)；预测区间在变换后的尺度上计算再反变换，这保持了概率覆盖率但失去了对称性<sup>[18](https://otexts.com/fpptr/ftransformations.html)</sup>。R 的 fable 包在模型定义中包含变换时会自动反变换预测值<sup>[18](https://otexts.com/fpptr/ftransformations.html)</sup>。

## 逆变换、反变换与陷阱

Box–Cox 逆变换为：当 λ = 0 时 \( \exp(X_{\text{trans}}) \)，否则为 \( (X \cdot \lambda + 1)^{1/\lambda} \)；Yeo–Johnson 的逆变换依 X 的符号以及 λ 是否等于 0 或 2 而分四种情形<sup>[17](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)</sup>。

**中位数与均值。** 简单反变换后的点预测通常是预测分布的中位数而非均值。偏差校正的均值需要校正因子，例如 λ = 0 时的 \( \exp(\hat{w})[1 + \sigma_h^2/2] \)，且差异随预测方差增大；当预测值必须聚合时该调整很重要，因为中位数不可加而均值可加<sup>[18](https://otexts.com/fpptr/ftransformations.html)</sup>。在对数尺度上，回归中同样的问题会出现：由于 Jensen 不等式，对预测均值取指数得到的东西更接近几何均值，因此朴素的反变换预测偏低，当需要算术均值时，Duan 的涂抹估计量可加以校正<sup>[15](https://casrai.org/guides/log-and-other-data-transformations)</sup>。

**失效模式。** 应用幂变换并不保证变换后的特征服从正态分布；依位置、尺度和离群值的不同，它可能降低正态性，导致错误的方差分析结果或使假定正态性的方法性能下降，且较大的 |λ| 可能引发数值问题<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。scikit-learn 在六种分布（对数正态、卡方、威布尔、高斯、均匀和双峰）上的演示表明，变换对某些分布有效，但对另一些则无效，尤其是多峰数据；对于对数正态和卡方数据，Box–Cox 的表现优于 Yeo–Johnson，但不接受负输入<sup>[16](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)</sup>。R 包 power.transform 直言，均匀分布或多峰数据无法合理地变换为正态，并提供了一个中心正态性的拟合优度 p 值，中心正态性定义为变换后数据的中心 80% 近似服从正态分布<sup>[19](https://cran.r-project.org/web/packages/power.transform/refman/power.transform.html)</sup>。

一个结构性局限是截断：当 λ > 0 时 \( h(y,\lambda) \) 有下界 \( -1/\lambda \)，当 λ < 0 时有上界，因此除非 λ = 0，否则精确正态性与变换后的变量不相容；对偶幂变换消除了这一界限，并生成跨正态分布，这是一个用于持续时间和事件时间的灵活三参数族<sup>[20](https://www.sciencedirect.com/science/article/abs/pii/S0165176506000188)</sup>。

## 近期进展

λ 的最大似然估计对离群值敏感，这促使 Raymaekers 与 Rousseeuw（2024）提出了 Box–Cox 和 Yeo–Johnson 的稳健版本；一篇 2026 年的《机器学习》论文引入了位置和尺度不变的变体，带有平移参数 \( x_0 \) 和尺度参数 s，以及稳健改编和经验中心正态性检验<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。R 包 power.transform 实现了位置和尺度不变的变换，通过最大化正态对数似然估计 λ，并在存在负值或零值时为 Box–Cox 将特征值平移至正域<sup>[19](https://cran.r-project.org/web/packages/power.transform/refman/power.transform.html)</sup>。

实现质量也已成为研究课题。幂变换的直接实现存在严重的数值不稳定性，可能导致错误结果或崩溃；一篇 PMLR 论文分析了其来源，提出了补救措施，并将幂变换扩展到联邦学习场景<sup>[2](https://proceedings.mlr.press/v300/xu26d.html)</sup>。在一项涵盖 231 个带数值特征数据集的机器学习实验中，将稳健的位置和尺度不变变换整合进自动化流程，与传统变体相比，对模型性能既无有意义的提升也无损害<sup>[7](https://link.springer.com/article/10.1007/s10994-026-06994-3)</sup>。2025 年 2 月的一篇 arXiv 预印本提出了另一种幂变换，声称统一了损失函数族、核函数族、概率分布族、隆起函数族和神经网络激活函数族，其特例包括 λ = 1 时的 \( \exp(x) - 1 \) 和 λ = −1 时的 \( \log(1+x) \)<sup>[21](https://arxiv.org/html/2502.10647)</sup>。

## References

1. [Atkinson, A. C., Riani, M., & Corbellini, A. (2021). The Box–Cox Transformation: Review and Extensions. Statistical Science 36(2), 239–255.](https://researchonline.lse.ac.uk/id/eprint/103537/1/StatSciV4.pdf)
2. [Power Transform Revisited: Numerically Stable, and Federated. PMLR v300.](https://proceedings.mlr.press/v300/xu26d.html)
3. [The nonparametric Box–Cox model for high-dimensional regression analysis. Journal of Econometrics.](https://www.sciencedirect.com/science/article/abs/pii/S0304407623000568)
4. [Box, G. E. P., & Cox, D. R. (1964). An Analysis of Transformations. JRSS Series B.](https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1964.tb00553.x)
5. [Transformations (textbook chapter). Springer.](https://link.springer.com/chapter/10.1007/978-3-031-88365-1_6)
6. [powerTransform: Finding Univariate or Multivariate Power Transformations. R car package documentation.](https://search.r-project.org/CRAN/refmans/car/html/powerTransform.html)
7. [Location and Scale-Invariant Power Transformations for Transforming Data to Normality. Machine Learning (Springer).](https://link.springer.com/article/10.1007/s10994-026-06994-3)
8. [Transformations. Online Statistics Education.](https://onlinestatbook.com/2/transformations/transformations.pdf)
9. [Box–Cox transformation. Encyclopedia of Mathematics.](https://encyclopediaofmath.org/wiki/Box%E2%80%93Cox_transformation)
10. [What do we do when data are non-normal. NIST/SEMATECH e-Handbook.](https://www.itl.nist.gov/div898/handbook/pmc/section5/pmc52.htm)
11. [scipy.stats.boxcox. SciPy v1.18.0 Manual.](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.boxcox.html)
12. [Yeo–Johnson Power Transformations. University of Minnesota Applied Statistics Center.](https://www.stat.umn.edu/arc/yjpower.pdf)
13. [PowerTransformer. Feature-engine user guide.](https://feature-engine.trainindata.com/en/latest/user_guide/transformation/PowerTransformer.html)
14. [PROC TRANSREG BOXCOX transformation. SAS documentation.](https://go.documentation.sas.com/api/docsets/statug/v_023/content/statug_transreg_details02.htm)
15. [Log and Other Data Transformations: When to Use Them and What They Cost. CASRAI.](https://casrai.org/guides/log-and-other-data-transformations)
16. [Map data to a normal distribution. scikit-learn example.](https://scikit-learn.org/stable/auto_examples/preprocessing/plot_map_data_to_normal.html)
17. [sklearn.preprocessing.PowerTransformer. scikit-learn documentation.](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PowerTransformer.html)
18. [Forecasting using transformations. Forecasting: Principles and Practice, 3rd ed.](https://otexts.com/fpptr/ftransformations.html)
19. [power.transform reference manual. CRAN.](https://cran.r-project.org/web/packages/power.transform/refman/power.transform.html)
20. [A modified family of power transformations. Economics Letters.](https://www.sciencedirect.com/science/article/abs/pii/S0165176506000188)
21. [A Power Transform. arXiv, February 2025.](https://arxiv.org/html/2502.10647)

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

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Probability theory › Probability distributions › Distribution families and classification › Location–scale and shape parameterization

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/power-transform

English original: https://www.edgepedia.org/power-transform
