Log Transformation Calculator
A logarithmic transformation is a non-linear transformation that shrinks large values disproportionately and pulls a right-skewed distribution toward symmetry. For variables that grow multiplicatively — income, company revenue, illness duration, reaction time, website traffic — it is an almost standard preprocessing step, because for those variables equal ratios carry more meaning than equal differences.
This calculator does not just apply the transformation; it tells you with numbers whether it worked. It computes skewness and kurtosis separately before and after, reports the drop in absolute skewness as a percentage, and runs the Shapiro-Wilk normality test on both series. When the data contains zeros or negative values, where ln and log₁₀ are undefined, it steers you to the log(x + 1) option, and the before-and-after histograms and Q-Q plots let you confirm the result visually as well.
Logarithmic Transformation Formulas
Natural logarithm: y = ln(x), x > 0 inverse: x = eʸ Base 10: y = log₁₀(x), x > 0 inverse: x = 10ʸ Data with zeros: y = ln(x + 1), x > −1 inverse: x = eʸ − 1 General shift: y = ln(x + c), c > −min(x) Base relationship: log₁₀(x) = ln(x) / ln(10) = ln(x) / 2.302585 Skewness: g₁ = [n / ((n−1)(n−2))] · Σ((yᵢ − ȳ) / s_y)³ Geometric mean: GM = exp(ȳ) = ⁿ√(x₁·x₂·…·xₙ)
The success of the transformation is measured by whether |g₁| gets smaller afterwards. A value of |g₁| < 0.5 counts as approximate symmetry and |g₁| > 1 as marked skewness. A logarithm only helps with right-skewed data (g₁ > 0).
How to Calculate
- Paste the values you want to transform into the box; at least 5 observations are required, because skewness and kurtosis are not reliable in smaller samples.
- Choose the transformation type: ln if you will interpret the result as an elasticity, log₁₀ if you will read it as fold growth.
- If your data contains zeros, switch to ln(x + 1) or log₁₀(x + 1); the plain logarithm is undefined at zero.
- Compare the before and after values of the skewness in the results panel; the 'Verdict on the transformation' row states outright whether it helped.
- Check the Shapiro-Wilk p-values: a p-value that rises above 0.05 after the transformation means normality is no longer rejected.
- Inspect the before-and-after histograms together with the Q-Q plots to confirm the numerical result visually.
Worked Examples
Right-skewed income data
The skewness of the 12 income values is 2.026; after the ln transformation it drops to 0.242, so the absolute skewness falls by 88.1% and the distribution becomes approximately symmetric. Kurtosis drops from 4.679 to −0.013, and while the Shapiro-Wilk test rejects normality before the transformation with p = 0.008, it does not reject it afterwards.
Sample size (n): 12 · Transformation applied: y = ln(x) · Skewness — before the transformation: 2.026
Count data containing zeros
Because the data contains zeros, ln(x) is undefined; with ln(x + 1) the skewness falls from 2.062 to 0.308, a reduction of 85.0% in absolute skewness. The Shapiro-Wilk p-value rises from 0.002 to 0.812, so normality is no longer rejected.
Sample size (n): 12 · Transformation applied: y = ln(x + 1) · Skewness — before the transformation: 2.062
A case where the log transformation does not help
On a left-skewed series of scores, the log₁₀ transformation moves the skewness from −0.534 to −0.620; instead of falling, the absolute skewness rises by 16.1% and the calculator reports the outcome as 'The transformation did not help'. The warning line points to a square or cube transformation for left-skewed data.
Sample size (n): 12 · Transformation applied: y = log₁₀(x) · Skewness — before the transformation: -0.534