Linear to logarithmic scale conversion

Click For Summary

Discussion Overview

The discussion revolves around converting linear scale values to a logarithmic scale for graph representation in a computer program. Participants explore how to implement this transformation while ensuring the output values remain within the range of 0 to 1.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes a method for normalizing values on a linear scale using the formula x'i=(xi-xmin)/(xmax-xmin).
  • Another participant clarifies their intent to create log-log plots and seeks a similar normalization approach for logarithmic values.
  • A suggestion is made to use the formula x'i = (log(xi)-log(xmin)) / (log(xmax)-log(xmin)) for the logarithmic scale transformation, with an example provided to illustrate its application.

Areas of Agreement / Disagreement

Participants appear to agree on the approach to transform logarithmic values, but the implementation details in the programming context remain open for further discussion.

Contextual Notes

There is an assumption that the logarithmic values are valid and that xmin and xmax are positive, as logarithms are undefined for non-positive values.

Who May Find This Useful

Individuals interested in programming graph representations, particularly those working with logarithmic scales in data visualization.

jocasa
Messages
4
Reaction score
0
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!
 
Physics news on Phys.org
jocasa said:
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!

Welcome to the PF.

What language are you programming in? Does it have any math libraries that cover logarithms?
 
I'm using C++ and it has both log and log10 functions, that is, log in base e and log in base 10.

I'm not sure if I made myself clear in my first post. I want to be able to make log-log plots, transforming the resulting plot into the [0,1] interval.
 
jocasa said:
Hi!

I'm making a computer program that represents some quantities in a graph in this way:

x'i=(xi-xmin)/(xmax-xmin)

so that the possible values of x range from 0 to 1. This is a linear scale. I want to do the same with the logarithmic values of xi. That is, I want to implement a log scale in my graphs, also in the range from 0 to 1.

Can anyone tell me how to do it?

Thanks!
I think this will work:

x'i = (log(xi)-log(xmin)) / (log(xmax)-log(xmin))​
As a test, we can see that if xmin,max are 1 and 100, then xi=10 gives x'i=0.5. As it should, since 10 is halfway between 1 and 100 on a log scale.
 
Thanks! It makes sense to me. Now the problem is to implement it in the program, but I won't bother you with such a thing. Thanks again from Spain!
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 6 ·
Replies
6
Views
13K
  • · Replies 7 ·
Replies
7
Views
13K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K