Logarithms for Skew and Growth
Most Pantry baskets cost between ₹300 and ₹800. A handful of office pantries order ₹40,000 of snacks at once. Plot order values on an ordinary axis and you get one tall spike near zero and a long, empty tail. Plot the monthly orders of a fast-growing new delivery zone and the early months look flat. Both pictures are fixed by the same tool.
The rule
Logs turn multiplying into adding: equal ratios become equal steps.
The base-10 logarithm asks "10 to what power gives this number?"
| Value | ₹40 | ₹400 | ₹4,000 | ₹40,000 |
|---|---|---|---|---|
| log10 | 1.6 | 2.6 | 3.6 | 4.6 |
Each step of ×10 in value is a step of +1 in the log. On a log axis, ₹400 and ₹4,000 sit as far apart as ₹4,000 and ₹40,000, so both ordinary baskets and office orders become visible on one chart.
Three reasons data scientists reach for logs:
- Skewed data such as order values, incomes and page views spreads out evenly.
- Growth at a steady percentage rate draws a straight line on a log scale, so a bend means the growth rate itself changed.
- Ratios become differences: . Doubling is always +0.301 in log10 and halving is always −0.301, which makes rises and falls symmetric, unlike percentages.
The natural log (written ln, base ) has a handy extra: for small changes, a rise of 0.05 in ln is close to a 5% rise in the value. That is why models often predict the log of spend, and why their coefficients read as percentages.
One catch: the log of zero does not exist. For a column with zeros, such as spend in a week with no orders, use , which keeps zeros at zero.
The shortcut
Count the zeros, then add the log of what is left. For 4,000: three zeros give 3, and log10(4) is about 0.6, so the answer is about 3.6. To compare two values, subtract their logs, because a difference of logs is the log of their ratio.
The raw counts
Monthly orders: 1,000, then 2,000, 4,000 and 8,000. On a normal axis the line curves sharply upward.
Drills
Answer fast — trust the rule.
Pantry's orders grow by 20% every month. On a log-scale chart, the line looks:
Which Pantry column is the best candidate for a log transform?
A column of weekly spend has many zeros. Why use log(1 + x) instead of log(x)?
Remember
- Logs turn ratios into steps: each ×10 is +1 in log10.
- Count the zeros, add the log of the rest; subtract logs to compare values.
- Trap: the log of zero. Use log(1 + x) for columns that contain zeros.
