Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Linear scale to Logarithmic

Tags:

math

logarithm

I have a linear scale that ranges form 0.1 to 10 with increments of change at 0.1:
  |----------[]----------|
0.1         5.0         10

However, the output really needs to be:
  |----------[]----------|
0.1         1.0         10 (logarithmic scale)

I'm trying to figure out the formula needed to convert the 5 (for example) to 1.0. Consequently, if the dial was shifted halfway between 1.0 and 10 (real value on linear scale being 7.5), what would the resulting logarithmic value be? Been thinking about this for hours, but I have not worked with this type of math in quite a few years, so I am really lost. I understand the basic concept of log10X = 10y, but that's pretty much it.

The psuedo-value of 5.0 would become 10 (or 101) while the psuedo-value of 10 would be 1010. So how to figure the pseudo-value and resulting logarithmic value of, let's say, the 7.5?

Let me know if addition information is needed.

Thanks for any help provided; this has beaten me.

like image 362
TurdPile Avatar asked Oct 20 '13 00:10

TurdPile


People also ask

How do you convert a linear scale to a logarithmic scale?

You asked to convert linear to logarithmic, and you just plug the numbers into the formula. In this case, the linear input of 5.00 would become 1.02 on the logarithmic scale. @TurdPile: The linear 5.00 would correspond to 1.00 exactly if the linear scale started at 0.0, but it starts at 0.1, hence the difference.

What is the difference between linear and logarithmic scale?

Key TakeawaysA logarithmic price scale uses the percentage of change to plot data points, so, the scale prices are not positioned equidistantly. A linear price scale uses an equal value between price scales providing an equal distance between values.

How do you convert log to normal scale?

You can convert the log values to normal values by raising 10 to the power the log values (you want to convert). For instance if you have 0.30103 as the log value and want to get the normal value, you will have: "10^0.30103" and the result will be the normal value.

How do you calculate log scale?

The equation y = log b (x) means that y is the power or exponent that b is raised to in order to get x. The common base for logarithmic scales is the base 10.

What is a logarithmic scale?

A logarithmic scale, often called a log scale, shows the percentage (relative) change. If an asset rises from 50 to 60, a rise of 20%, it’s presented in the same way as a change from 10 000 to 12 000 (also a 20% rise). If we change the linear scale from the pic above to log scale (logarithmic scale), the scale changes significantly:

Which is better linear or logarithmic chart?

Logarithmic charts are better than linear charts and scales – hands down. The difference between linear and logarithmic charts grows bigger as time goes by. Thus, log scale is always better than a linear scale. We recommend using logarithmic scales as default in your charting.

What is the difference between log scale vs linear scale?

In trading, it’s important to understand log scale vs linear scale. Logarithmic charts are better than linear charts and scales – hands down. The difference between linear and logarithmic charts grows bigger as time goes by. Thus, log scale is always better than a linear scale. We recommend using logarithmic scales as default in your charting.

How to calculate exponentiation from logarithm?

p = p 0 10 L P / 20. Setting aside the false premise of your colleague's critique, which whuber and I discuss in the comments, the answer to your question is very straightforward: Exponentiation is the inverse of the logarithm function. If your data on the log a scale are x, then on the linear scale they are y such that y = a x for a > 0.


1 Answers

Notation

As is the convention both in mathematics and programming, the "log" function is taken to be base-e. The "exp" function is the exponential function. Remember that these functions are inverses we take the functions as:

exp : ℝ → ℝ+, and

log : ℝ+ → ℝ.

Solution

You're just solving a simple equation here:

y = a exp bx

Solve for a and b passing through the points x=0.1, y=0.1 and x=10, y=10.

Observe that the ratio y1/y2 is given by:

y1/y2 = (a exp bx1) / (a exp bx2) = exp b(x1-x2)

Which allows you to solve for b

b = log (y1/y2) / (x1-x2)

The rest is easy.

b = log (10 / 0.1) / (10 - 0.1) = 20/99 log 10 ≈ 0.46516870565536284

a = y1 / exp bx1 ≈ 0.09545484566618341

More About Notation

In your career you will find people who use the convention that the log function uses base e, base 10, and even base 2. This does not mean that anybody is right or wrong. It is simply a notational convention and everybody is free to use the notational convention that they prefer.

The convention in both mathematics and computer programming is to use base e logarithm, and using base e simplifies notation in this case, which is why I chose it. It is not the same as the convention used by calculators such as the one provided by Google and your TI-84, but then again, calculators are for engineers, and engineers use different notation than mathematicians and programmers.

The following programming languages include a base-e log function in the standard library.

  • C log() (and C++, by inclusion)

  • Java Math.log()

  • JavaScript Math.log()

  • Python math.log() (including Numpy)

  • Fortran log()

  • C#, Math.Log()

  • R

  • Maxima (strictly speaking a CAS, not a language)

  • Scheme's log

  • Lisp's log

In fact, I cannot think of a single programming language where log() is anything other than the base-e logarithm. I'm sure such a programming language exists.

like image 138
Dietrich Epp Avatar answered Sep 29 '22 03:09

Dietrich Epp