[HN Gopher] Logarithmic Scales
       ___________________________________________________________________
        
       Logarithmic Scales
        
       Author : lucasfcosta
       Score  : 45 points
       Date   : 2024-05-08 11:25 UTC (1 days ago)
        
 (HTM) web link (briefer.cloud)
 (TXT) w3m dump (briefer.cloud)
        
       | breck wrote:
       | Nice read. (Any chance you could add an RSS feed or similar?)
        
       | darkest_ruby wrote:
       | would have been a great article if used metric. I cant imaine
       | what 100 inches is, let alone 1000 inches
        
         | KineticLensman wrote:
         | > Notice how we're not using the ruler for measuring anymore.
         | Instead, we're using it to represent the sizes of different
         | objects.
         | 
         | Viewed like this, the fact that it uses inches vs m isn't
         | significant, because 'inches' translates as 'units'. Even as a
         | Brit, I can't imagine 1000 inches either, but I can tell
         | something about two objects that are respectively 1000 vs 1200
         | inches/units.
        
         | HarHarVeryFunny wrote:
         | Well, for mental math 1000 inches ~ 1200 inches (100 ft).
         | 
         | Or converting to meters: 100 ft / 3 = 33 yards ~ 33 meters.
         | 
         | Since we added 20% in the first place (1200 vs 1000), 33 - 20%
         | = 27m is better estimate (actual = 25m).
        
         | nerdponx wrote:
         | If you replaced the '"' with 'cm', the analysis and
         | visualizations would be identical.
        
       | leeoniya wrote:
       | another nice one is Inverse Hyperbolic Sine scale, which can
       | reach 0 and plot negative values, whereas log scales cannot. imo
       | it's nicer than a cube root scale, too.
       | 
       | https://leeoniya.github.io/uPlot/demos/arcsinh-scales.html
       | 
       | cube root:
       | https://en.wikipedia.org/wiki/Cube_root#/media/File:Cube-roo...
       | 
       | vs arcsinh:
       | https://upload.wikimedia.org/wikipedia/commons/9/92/Inverse_...
       | 
       | some interactive log scale demos:
       | 
       | https://leeoniya.github.io/uPlot/demos/log-scales.html
       | 
       | https://leeoniya.github.io/uPlot/demos/log-scales2.html
        
         | kccqzy wrote:
         | Wow. This is the first time in hearing about the inverse
         | hyperbolic sine scale. I wonder if it's lesser known simply
         | because many kinds of real-world underlying data that needs
         | logarithmic scales simply don't have zeroes or negative values?
         | For example we might be plotting some data that actually comes
         | from an underlying exponential distribution?
        
           | leeoniya wrote:
           | i think sometimes it's called symlog, though i'm not sure if
           | that's just a convenient re-naming of arcsinh. i don't see
           | how any kind of "log" scale can do <= 0.
           | 
           | you can always y-flip the result of log(abs(value)) and show
           | neg ticks on the axis, but it will not be a nicely-
           | continuous, single scale that can cross 0.
           | 
           | https://stackoverflow.com/questions/3305865/what-is-the-
           | diff...
        
             | eaglefield wrote:
             | Symlog is symmetric log. It's not arcsinh, instead it's a
             | normal logarithmic scale, that turns into a linear scale
             | around zero (for example in the range [-1,1]) and then it
             | turns into a negative logarithm on the other side of zero.
             | So similar but slightly different.
             | 
             | https://matplotlib.org/stable/gallery/scales/symlog_demo.ht
             | m...
             | 
             | for an example.
        
               | leeoniya wrote:
               | > that turns into a linear scale around zero
               | 
               | how does this actually work? afaik, there is no log() fn
               | that you can run which "becomes linear". i guess you can
               | wrap a call to log() in another fn that simply does
               | linear scaling below the defined threshold, but it's not
               | a smooth transition without a bunch of extra [possibly
               | slow] smoothing code.
               | 
               | what you're describing is exactly how a straight call to
               | Math.asinh() behaves, and what i have implemented in the
               | above demo.
        
               | eaglefield wrote:
               | Theres no smoothing involved, it's three distinct domains
               | with different function definitions. Top part is log(x)
               | from [a,\infty), bottom part is -log(-x) from
               | (-\infty,-a] and the middle part is cx from (-a,a). With
               | c chosen to ensure continuity in the transform.
               | 
               | In the example from matplotlib I linked in the earlier
               | comment they call out that the symlog transform has a
               | discontinous gradient at the a's, and that the asinh
               | transform can be used instead if that's a problem.
               | 
               | Edit: On reflection it's probably not entirely correct to
               | talk about it as choosing an appropriate c. Since that
               | transform seems to kinda break apart around a=1. Simpler
               | to consider it a matter of plotting on a logarithmic
               | scale down to some value. Then continuing the plot on a
               | linear scale until you reach the negative value on the
               | other side and then plotting on a negative logarithmic
               | scale (-log(|x|)).
        
           | nerdponx wrote:
           | It's also harder to interpret. What the heck does `log(x +
           | sqrt(x^2 + 1))` mean?
           | 
           | It's a great transformation for data viz or machine learning
           | / statistical modeling, but its not really obvious what an
           | IHS-transformed variable represents.
        
         | ForOldHack wrote:
         | This is brilliant. I used a logarithmic cosine scale in college
         | physics for the degradation of a Cavindish balence. It won me
         | both a guest lecture and an easy A.
         | 
         | There are even wilder triple hyperbolic scales on three
         | dimensions.
        
       | JKCalhoun wrote:
       | I tried to create a logarithmic widget for the web for anyone to
       | grab. I like logarithmic interfaces -- think there are probably a
       | lot of uses for them.
       | 
       | I don't exactly know what I am doing when I venture into
       | Javascript and web stuff but here you go:
       | 
       | https://github.com/EngineersNeedArt/SlideRule
       | 
       | There's a demo page off the link above. It's a janky Ohm's Law
       | calculator. (The top slider & text field are read-only, BTW.)
        
       | jesuslop wrote:
       | Very natural also in money/investing applications. Passing to log
       | scale asset prices follow random walks in several finance
       | applications and behave much better in this scale. Options price
       | formulas by rote memory are a bit of a mess because one does a
       | log-calculate-exp kind of thing that distorts the streamlined
       | rationale of the inner simpler calculations. Geometric means
       | (used in CAGR, compound aggregate growth rates, for yearly
       | returns) become just means (=arithmetic means) in log scale.
        
         | kccqzy wrote:
         | Agreed. Any stock app that doesn't plot stock prices in log
         | scale is considered by me to be an amateur app. My favorite
         | litmus test for stock apps is to view the ten-year price
         | history for UVXY. If it doesn't look roughly like a straight
         | line the app is for amateurs. The iOS built in stock app fails
         | this test. The Schwab app passes this test.
        
       | kkoncevicius wrote:
       | Since it is on topic - sharing useful link I have in my bookmarks
       | about transformations in general:
       | http://fmwww.bc.edu/repec/bocode/t/transint.html
        
       | mif wrote:
       | The graph named "non-linear growth", is actually showing linear
       | growth. I know, it's confusing, but as long as the factor is
       | constant (10), growth is linear.
       | 
       | A quick way to check if something grows linearly is to put it on
       | a log-scale and to see whether it's a straight line.
       | 
       | Nice explanation, though. We should talk about logs more often.
        
         | kccqzy wrote:
         | I think you and the author are using terminology differently.
         | That graph is absolutely a logarithmic axis to me. The five
         | ticks on the axis are equidistant but each represents a number
         | 10x of the previous. That's nonlinear to me. My definition of
         | linear growth is that it is bounded above by a linear function.
         | Its first derivative would therefore be bounded above by a
         | constant.
         | 
         | If something is a straight line when you plot it in log scale,
         | you are plotting exponential growth.
        
         | nerdponx wrote:
         | "Linear" here doesn't mean "a linear transformation is applied
         | at each time step", it means "a constant rate of change over
         | all time".
         | 
         | Multiplicative growth by a constant factor is an _increasing_
         | rate of change over time.
        
       | levocardia wrote:
       | It doesn't really matter what log base you use, visually
       | speaking. All log bases are just multiplicative differences from
       | one another: it's like asking whether it matters if you plot
       | height using feet or meters. It just affects where your ticks go.
        
         | leeoniya wrote:
         | yep, this was a fun aspect i discovered when doing the
         | implementation as well. the log base just affects the tick/grid
         | selection and where you might want to "nicely" snap the min and
         | max to.
        
       ___________________________________________________________________
       (page generated 2024-05-09 23:00 UTC)