Rosetta Stone · 24 of 30
Logarithm
Function
In plain English
"How many times do I multiply the base to get this number?" ; . Logs turn multiplication into addition (), compress huge ranges into readable ones, and turn power laws into straight lines on a log-log plot. is the surprise of an event with probability : rare events are very surprising. The base sets the units (base 2 gives bits, base e gives nats) and is often omitted in papers.
As code
Math.log10(1000); // 3
Math.log2(8); // 3
Math.log(Math.E); // 1 (natural log, base e)
-Math.log2(1 / 8); // 3 bits of surpriseSee it
What it means, field by field
Inverse of exponentiation; log-log plots linearise power laws.
Log-likelihood and cross-entropy loss; log-scale axes for compute and parameters; log-probabilities (logits are unnormalised log-probabilities).
Boltzmann entropy S = k_B log W; decibels; magnitudes in astronomy.
pH (−log₁₀ of hydrogen-ion concentration); log fold-change in gene expression; sequence logos measured in bits.
In a research paper
Entropy grows with the number of microscopic arrangements consistent with what you observe, but only logarithmically.
Common misreadings
Assuming log means base 10. In ML and physics it is usually the natural log, but check.
Reading straight lines on log-log plots as proof of a power law. Many curves look straight over two decades.
Treating a small change in log loss as small. 0.1 nats is a substantial improvement at the frontier.