📚 Logarithmic Transformations in Handling Nonlinear Data | 对数变换在处理非线性数据中的应用
In data analysis and mathematical modelling, many real-world processes do not follow a straight line. When faced with nonlinear patterns, one of the most powerful and elegant tools is the logarithmic transformation. It allows us to convert certain types of curved relationships into linear ones, making them easier to analyse, interpret, and visualise.
在数据分析和数学建模中,许多现实世界中的过程并不遵循直线规律。当面对非线性模式时,最强大且优雅的工具之一就是对数变换。它使我们能够将某些类型的曲线关系转化为线性关系,从而更容易进行分析、解释和可视化。
1. What Is a Logarithmic Transformation? | 什么是对数变换?
A logarithmic transformation applies the logarithm function to one or both variables in a dataset. For example, instead of working with raw values \(x\) and \(y\), we work with \(\ln x\) or \(\log_{10} y\). The natural logarithm \(\ln\) and the common logarithm \(\log\) are both commonly used; the choice often depends on the context, but the mathematical properties are similar.
对数变换是对数据集中的一个或两个变量应用对数函数。例如,我们不使用原始值 \(x\) 和 \(y\),而是使用 \(\ln x\) 或 \(\log_{10} y\)。自然对数 \(\ln\) 和常用对数 \(\log\) 都经常使用;选择通常取决于具体情境,但数学性质是相似的。
y = a xⁿ → ln y = ln a + n ln x
This transformation is not just a computational trick; it is deeply connected to the underlying multiplicative structure of many natural phenomena.
这种变换不仅仅是计算上的技巧;它与许多自然现象中潜在的乘法结构密切相关。
2. Why Does It Work for Nonlinear Data? | 为什么它对非线性数据有效?
Logarithmic transformation works because logarithms turn multiplication into addition and powers into products. This property is expressed by the identities:
对数变换之所以有效,是因为对数将乘法转化为加法,将幂转化为乘积。这一性质由以下恒等式表达:
log(xy) = log x + log y, log(xⁿ) = n log x
When a relationship is multiplicative in the original variables, applying logarithms produces an additive relationship, which is linear. For example, if \(y = a x^n\), then \(\ln y = \ln a + n \ln x\), which is a straight line when \(\ln y\) is plotted against \(\ln x\).
当原始变量之间是乘法关系时,应用对数后会产生加和关系,即线性关系。例如,如果 \(y = a x^n\),则 \(\ln y = \ln a + n \ln x\),当 \(\ln y\) 对 \(\ln x\) 作图时是一条直线。
3. Common Nonlinear Relationships and Their Linearization | 常见的非线性关系及其线性化
Several classic nonlinear forms can be linearized by taking logarithms. The two most important families are exponential relationships and power-law (power function) relationships.
几种经典的非线性形式可以通过取对数来线性化。其中最重要的两类是指数关系和幂律(幂函数)关系。
-
Exponential: \(y = a b^x\) → \(\ln y = \ln a + x \ln b\) (linear in \(x\) with slope \(\ln b\))
指数: \(y = a b^x\) → \(\ln y = \ln a + x \ln b\)(关于 \(x\) 线性,斜率为 \(\ln b\))
-
Power law: \(y = a x^n\) → \(\ln y = \ln a + n \ln x\) (linear in \(\ln x\) with slope \(n\))
幂律: \(y = a x^n\) → \(\ln y = \ln a + n \ln x\)(关于 \(\ln x\) 线性,斜率为 \(n\))
Other forms, such as \(y = a e^{kx}\), are special cases of exponential relationships where \(b = e^k\).
其他形式,如 \(y = a e^{kx}\),是指数关系的特例,其中 \(b = e^k\)。
4. Power Law Relationships | 幂律关系
A power law relationship has the form \(y = a x^n\), where \(a\) and \(n\) are constants. Taking the natural logarithm of both sides gives:
幂律关系具有形式 \(y = a x^n\),其中 \(a\) 和 \(n\) 是常数。对方程两边取自然对数得到:
ln y = ln a + n ln x
If we define new variables \(Y = \ln y\) and \(X = \ln x\), then the equation becomes \(Y = n X + \ln a\), which is a straight line. The slope \(n\) tells us the power or scaling exponent, and the intercept gives \(\ln a\).
如果我们定义新变量 \(Y = \ln y\) 和 \(X = \ln x\),则方程变为 \(Y = n X + \ln a\),这是一条直线。斜率 \(n\) 告诉我们幂指数,截距给出 \(\ln a\)。
This is useful in physics, biology, and economics. For example, the relationship between the mass of an animal and its metabolic rate often follows a power law with an exponent around 0.75.
这在物理学、生物学和经济学中很有用。例如,动物体重与其代谢率之间的关系通常遵循指数约为 0.75 的幂律。
5. Exponential Relationships | 指数关系
An exponential relationship has the form \(y = a b^x\) or \(y = a e^{kx}\). Taking the natural logarithm of both sides yields:
指数关系具有形式 \(y = a b^x\) 或 \(y = a e^{kx}\)。对方程两边取自然对数得到:
ln y = ln a + x ln b
Here, \(\ln y\) is a linear function of \(x\). The slope \(\ln b\) represents the continuous growth rate if \(b = e^k\). Population growth, radioactive decay, and compound interest all exhibit this pattern.
这里,\(\ln y\) 是 \(x\) 的线性函数。斜率 \(\ln b\) 代表连续增长率(如果 \(b = e^k\))。人口增长、放射性衰变和复利都表现出这种模式。
When plotted on a graph with a logarithmic y-axis, an exponential curve appears as a straight line. This is the basis of semi-log plots.
当在具有对数 y 轴的图上绘制时,指数曲线表现为一条直线。这是半对数图的基础。
6. Log-Linear and Log-Log Plots | 对数-线性和双对数图
There are two main types of transformed plots. A semi-log plot uses a logarithmic scale on one axis and a linear scale on the other. A log-log plot uses logarithmic scales on both axes.
变换后的图主要有两种类型。半对数图在一个轴上使用对数刻度,在另一个轴上使用线性刻度。双对数图在两个轴上均使用对数刻度。
-
Semi-log plot: Used to detect exponential relationships. If the data points form a straight line, then \(y\) is exponentially related to \(x\).
半对数图:用于检测指数关系。如果数据点形成一条直线,则 \(y\) 与 \(x\) 成指数关系。
-
Log-log plot: Used to detect power-law relationships. If the data points form a straight line, then \(y\) is a power function of \(x\).
双对数图:用于检测幂律关系。如果数据点形成一条直线,则 \(y\) 是 \(x\) 的幂函数。
These plots are widely used in scientific visualization because they compress wide-ranging data and reveal scaling behaviour.
这些图在科学可视化中广泛使用,因为它们能压缩范围广泛的数据并揭示标度行为。
7. Estimating Parameters from Linearized Plots | 从线性化图中估计参数
Once a nonlinear relationship has been transformed into a linear one, standard linear regression can be applied. The slope and intercept of the fitted line provide estimates of the original parameters.
一旦非线性关系被转化为线性关系,就可以应用标准线性回归。拟合直线的斜率和截距提供了原始参数的估计值。
For a power law \(y = a x^n\), after doing linear regression on \(\ln y\) versus \(\ln x\):
对于幂律 \(y = a x^n\),在对 \(\ln y\) 与 \(\ln x\) 进行线性回归之后:
slope = n, intercept = ln a → a = e^{intercept}
For an exponential model \(y = a b^x\), after regressing \(\ln y\) on \(x\):
对于指数模型 \(y = a b^x\),在将 \(\ln y\) 对 \(x\) 回归之后:
slope = ln b → b = e^{slope}, intercept = ln a → a = e^{intercept}
This method is easy to implement with calculators, spreadsheets, or statistical software.
这种方法很容易用计算器、电子表格或统计软件实现。
8. Example: Exponential Growth Model | 实例:指数增长模型
Consider a population of bacteria that doubles every hour. The model is \(N(t) = N_0 2^t\), where \(t\) is time in hours. Taking the natural logarithm gives:
考虑一个每小时翻倍的细菌种群。模型为 \(N(t) = N_0 2^t\),其中 \(t\) 是以小时为单位的时间。取自然对数得到:
ln N(t) = ln N_0 + t ln 2
If we plot \(\ln N\) against \(t\), we expect a straight line with slope \(\ln 2 \approx 0.693\). Suppose collected data yield a fitted line with slope 0.71 and intercept 4.8. Then we estimate \(N_0 = e^{4.8} \approx 121.5\), and the growth rate \(\ln b \approx 0.71\), so \(b \approx e^{0.71} \approx 2.03\), close to the true doubling factor 2.
如果我们绘制 \(\ln N\) 对 \(t\) 的图,期望得到一条斜率为 \(\ln 2 \approx 0.693\) 的直线。假设收集的数据拟合出的直线斜率为 0.71,截距为 4.8。那么我们估计 \(N_0 = e^{4.8} \approx 121.5\),增长率 \(\ln b \approx 0.71\),因此 \(b \approx e^{0.71} \approx 2.03\),接近真实的加倍因子 2。
9. Example: Power Law Model | 实例:幂律模型
Let \(y\) be the number of species in an area \(A\). The species-area relationship often follows \(S = c A^z\). Taking logarithms:
设 \(y\) 为某区域 \(A\) 中的物种数量。物种-面积关系通常遵循 \(S = c A^z\)。取对数:
log S = log c + z log A
Using common logarithms, a regression of \(\log S\) on \(\log A\) gives slope \(z\), which is often between 0.15 and 0.35 for different ecosystems. If the fitted slope is 0.25 and the intercept is 2.1, then \(c = 10^{2.1} \approx 126\). This allows ecologists to predict species richness in unvisited areas.
使用常用对数,将 \(\log S\) 对 \(\log A\) 回归得到斜率 \(z\),对于不同生态系统,\(z\) 通常在 0.15 到 0.35 之间。如果拟合斜率为 0.25,截距为 2.1,则 \(c = 10^{2.1} \approx 126\)。这使得生态学家能够预测未调查区域的物种丰富度。
10. Cautions and Limitations | 注意事项与局限性
Although logarithmic transformation is powerful, it is not a universal fix. It only linearizes specific types of nonlinearity, such as exponential or power-law forms. It cannot linearize arbitrary curves, for example \(y = \sin x\) or \(y = x^2 + x\).
尽管对数变换很强大,但它并非万能药。它只能线性化特定类型的非线性,如指数或幂律形式。它无法线性化任意曲线,例如 \(y = \sin x\) 或 \(y = x^2 + x\)。
Another pitfall is that taking logarithms changes the error structure. If the original data have additive errors, after transformation the errors become multiplicative or heteroscedastic. This can affect the validity of ordinary least squares regression.
另一个陷阱是取对数会改变误差结构。如果原始数据具有加性误差,变换后误差变为乘性或异方差性。这可能影响普通最小二乘回归的有效性。
Also, logarithms are only defined for positive values. Zero or negative data require adjustments, such as adding a constant, which can bias results.
此外,对数仅对正数有定义。零或负数据需要调整,例如加一个常数,但这可能会使结果产生偏差。
11. Practical Steps for Using Log Transformations | 使用对数变换的实用步骤
When you encounter a nonlinear dataset, a systematic approach is helpful.
当你遇到非线性数据集时,系统性的方法很有帮助。
-
Plot the raw data. Determine whether the pattern resembles exponential growth/decay or a power law.
绘制原始数据图。判断模式是否类似于指数增长/衰减或幂律。
-
Apply the appropriate transformation: take the logarithm of \(y\) alone for exponential, or of both \(x\) and \(y\) for power-law.
应用适当的变换:对指数关系仅对 \(y\) 取对数,对幂律关系对 \(x\) 和 \(y\) 都取对数。
-
Re-plot the transformed data. If the plot is roughly linear, the chosen model is appropriate.
重新绘制变换后的数据。如果图形大致为线性,则所选模型是合适的。
-
Fit a regression line, estimate parameters, and convert back to the original scale if needed.
拟合回归线,估计参数,如果需要则转换回原始尺度。
Always check the residuals after fitting to ensure that the linearized model is adequate.
拟合后务必检查残差,以确保线性化模型是合适的。
12. Conclusion | 总结
Logarithmic transformation is a cornerstone technique in mathematical modelling. It turns multiplicative and exponential structure into additive, linear structure, enabling straightforward analysis. By applying it carefully and understanding its limitations, data scientists and students can unlock meaningful patterns from nonlinear data.
对数变换是数学建模中的基石技术。它将乘性和指数结构转化为加性和线性结构,从而简化分析。通过谨慎应用并理解其局限性,数据科学家和学生可以从非线性数据中揭示有意义的模式。
Remember the two golden rules: use semi-log plots for exponential relationships, and log-log plots for power-law relationships. With these tools, a curved world becomes a straight path to insight.
请记住两条黄金法则:指数关系使用半对数图,幂律关系使用双对数图。有了这些工具,一个弯曲的世界将变成通往洞察的直线路径。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply