Search code examples
mathscalelogarithm

Convert log10-Data to a 1-11 scale


I want to convert my data to a 1-11 scale. At first, I took the raw data and converted them with the following formula, which I took from here:

scale_min + float(x-data_min)*float(scale_max-scale_min)/(data_max-data_min)

However, since my data has extreme outliers, this makes the differences in most of the data impossible to see. I thought about taking the log10 of the data and then converting those values to my 1-11 scale, however, the above formula does not work with negative values, which can occur with log10. Is there any other way of mapping log10 values to a 1-11 scale? Or any other way of mapping data with extreme outliers to a 1-11 scale in a way which makes differences in smaller values perceivable, while not losing any of the information?

An example for my values would be

[0.1, 10, 300, 500000]

Solution

  • I don't see a reason why your formula shouldn't work with negative numbers. It is a simple affine function.

    Example in python:

    from math import log10
    
    data = [0.1, 10, 300, 500000]
    
    logdata = [log10(x) for x in data]
    
    a = min(logdata)
    b = max(logdata)
    
    data1_11 = [1 + (y - a) * 10 / (b - a) for y in logdata]
    
    print(data1_11)
    # [1.0, 4.0, 6.2, 11.0]