17 · Log-normal distribution
If log(X) is Normal, X is log-normal — the natural model for prices, salaries, and anything that grows by multiplication.
If log(X) is Normal, then X is log-normal — the natural model for prices, salaries, response times, and anything multiplicative.
Without this:
Without it, you'd treat strongly right-skewed data as Normal and underestimate the tail risk.
A random variable X is log-normal if its logarithm is Normally distributed:
X is log-normal ⟺ log(X) ~ Normal(μ, σ²)
The parameters μ and σ are the mean and std of the log-scale Normal, not of X itself.
Why does log-normal arise? By the multiplicative analogue of the Central Limit Theorem: if X = X₁ · X₂ · … · Xn is the product of many independent positive factors (each close to 1), then log(X) = log(X₁) + … + log(Xn) is a sum of independent RVs → Normal by CLT. Therefore X is log-normal.
Key properties:
- Right-skewed PDF — a long right tail with many small values and rare large ones
- Mean > median — the mean is pulled up by the right tail; the median is a more robust centre
- The log-transform fixes it: log(X) ~ Normal → histogramming log(X) gives a bell curve
- Mean of X: E[X] = exp(μ + σ²/2)
- Median of X: exp(μ) (because exp is monotone and the median of log(X) is μ)
Real-world log-normal phenomena: Stock prices, salaries, response times, file sizes, city populations, income distributions, household net worth — any quantity that accumulates via multiplication (growth rates, infection spread, compound interest) ends up log-normal.
Universal EDA rule: When you see strong right-skew in a numeric feature, the first transform to try is np.log1p(x) (log(1 + x), which handles x=0 gracefully). In most cases it makes the distribution approximately Normal, enabling better regression models.
Python (in browser)
scipy.stats.lognorm(s=σ) creates a log-normal where s is the σ of the underlying Normal (μ=0 by default, set scale=exp(μ) to change it). Mean > median confirms the right skew. The PDF peaks well below 1 and has a long right tail.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Python (in browser)
Side-by-side: left panel is the right-skewed log-normal histogram; right panel is log(samples) — a near-perfect bell curve. The log-transform literally undoes the skew. Open /tmp/lognormal.png to view.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Python (in browser)
Products of 100 iid Normal(1, 0.1) factors are right-skewed (mean > median), while log(products) is approximately Normal with mean ≈ −0.5 and std ≈ 1.0. This is the multiplicative CLT: whenever a quantity is built from many multiplicative factors, it tends to log-normal.
Python runs entirely in your browser via Pyodide (~6 MB on first Run, cached after).
Stock prices, salaries, response times, file sizes, city populations — all follow log-normal distributions because they arise from multiplicative growth processes. The universal EDA fix is np.log1p(x): if the result looks Normal, use the log-transformed feature.
If log(X) ~ Normal(0, 1), what is the median of X?
- X is log-normal ⟺ log(X) ~ Normal(μ, σ²). Right-skewed PDF, mean > median, arises from multiplicative processes.
- **Median of X = exp(μ)** (invariant under the monotone exp transform). **Mean of X = exp(μ + σ²/2)** (pulled up by the right tail).
- The log-transform fixes right skew: log(X) ~ Normal. Use `np.log1p` in EDA on right-skewed features; predict log(y) for right-skewed regression targets.
Linear regression on log(price) is a universal pricing model. Geometric mean / multiplicative effects. Many ML metrics like AUC are scale-invariant precisely because of log-normal-style data.
If you remove it: Without log-transforms, your linear models choke on heavy-tailed targets.