Ah, the logarithm. It’s the black sheep of the mathematics family, loved by a few slide-rule wielding, grey-haired professors and math Olympiad competitors. For the rest of us, logarithms remain on the “I’ll get back to understanding that later when I see the point” shelf. However, this esoteric little function is actually a lot more common in real life (and a lot more useful) than you think.

If you haven’t dabbled with logarithms in a while, here’s a quick reminder:

A logarithm is the power to which a number is raised to get another number. For example, take the equation 10^2 = 100; The superscript “2” here can be expressed as an exponent (10^2 = 100) or as a base 10 logarithm. For example, the (base 10) logarithm of 100 is the number of times you’d have to multiply 10 by itself to get 100. In other words, the logarithm tells us what the exponent is!

If you don’t quite grasp the meaning, you’re not alone; Most students who study logarithms for the first time, with a definition similar to the one above, find it “…impossible to understand its relation to the real world” (Thoumasis, 1993) When I taught university-level algebra, the log only reared it’s head once or twice a year, and barely in a practical sense (there are graphing calculators to help with that!). I’ll be the first to admit that I despised logarithms about as much as my students.

Why do we have this strange scale, where not all jumps are equal? The simple answer is that logs make our life easier, because us human beings have difficulty wrapping our heads around very large (or very small) numbers. For example, it’s easier for me to read that my pool water has a pH of 7 (on a logarithmic scale) than a pH of 1 * 10^{-7} moles.

## Real Life Examples of Logarithms (in Everyday Life)

The Richter Scale for earthquakes is a classic example of a logarithmic scale in real life. One of the more interesting facts about this particular logarithmic scale is that it’s related to the length of the fault line. The largest earthquake ever recorded was a magnitude 9.5 on May 22, 1960 in Chile on a 1,000 mile long fault line (source: USGS). By comparison, a theoretical mag 10 earthquake would stretch for tens of thousands of miles ; A practical impossibility but it’s fairly easy to grasp that small jumps in numbers here mean huge changes, not small ones.

Decibels, light intensity and and pH (as in, my pool water testing kit) are all well-known logarithmic scales. However, “…any natural phenomenon that grows or decays at a rate proportional to its current value (such as population growth or compound interest) can be modeled with logarithms (Hughes, 1996).

A less well known application of logarithms is **password strength:**

“The information entropy H, in bits, of a randomly generated password consisting of L characters is given by H = L log

_{2}(N), where N is the number of possible symbols for each character in the password. In general, the higher the entropy, the stronger the password” (R.Frith).

In summation, is the average person really going to ever *use* a logarithm in real life? Probably not in the “nuts and bolts” sense of the word, but they are useful for many situations. Logarithms work in the same way that a computer chip works in your vehicle–alerting you to that needed oil change, faulty gasket, or open door. Without that chip, we’d be back to the days of troubleshooting a vehicle with a wrench and overalls. In the same way, there are plenty of real life examples of logarithms working under the hood–you just probably never have a reason to see them.

## Real Life Examples of Logarithms (for Data Scientists)

As far as data science goes, there are plenty of areas where logarithms crop up:

- Log odds play a central role in logistic regression. Every probability can be easily converted to
**log odds**, by finding the odds ratio and taking the log. Although they are no doubt useful, log odds are also a little esoteric. Jaccard (2001, p.10) calls them “…counter-intuitive and challenging to interpret.” - Logarithmic transformations are also extremely useful for making it easier to see patterns in data. When logarithmic transformation straightens out a function, it becomes the exponential function–making it much easier to read and more understandable (Burrill et. al, 1999).
- Logarithmic derivatives are a
**lot cleaner**for some complicated functions, as Fatos Marina’s points out in his TDS article Why Logarithms Are So Important In Machine Learning Although that’s an extremely good application of logarithms, manually taking derivatives isn’t exactly high on the top 100 tools for data science.

As logarithms can model so many different phenomena, it’s a very handy tool to add to your mathematical toolbox. That’s not to say that *all* data scientists should learn (or even care) about logarithms. Knowing what a logarithmic scale looks like is vitally important if you do a lot of modeling. If you don’t do any modeling? Well, that Richter scale “wrapping around the Earth” factoid makes for a great water cooler conversation.

**References**

Burrill et al. (1999). Modeling with Logarithms.

Hughes (1996). Question Corner: Natural Logs in the Real World. https://www.math.toronto.edu/mathnet/questionCorner/logsinlife.html

Jaccard, J. (2001) Interaction Effects in Logistic Regression, Issue 135. SAGE.

Thoumasis, C. (1993). Teaching Logarithm Via Their History, School Science and

Mathematics 8(12), 428-434

Credit: Data Science Central By: Stephanie Glen