Math Formula - mapping large range to smaller range of numbers

Discussion in 'App Development' started by OptionsOptionsOptions, Apr 15, 2020.

  1. I am looking for the math formula to map a large range of numbers to smaller range. Example:

    • Old range: 0-270
    • New range: 0-100


    Thanks
     
  2. Turveyd

    Turveyd

    New = Old / 2.7 ??

    Too simple, need more info maybe.
     
    • A = 0
    • B = 270
    • X = input (example 73)

    • C = 0
    • D = 100
    • Y = output ??????


    What is Y?
    I'm looking for the math formula.
     
  3. Turveyd

    Turveyd

    Y = 73 / 2.7 = 27.03

    Or X / B = 73 / 270 = ( .2703 * 100 ) or 27.03%

    D being 100, makes it easy as it's just a percent.

    If D = 50 then 73 / 5.4
     
  4. keesa

    keesa

    Y=X(D-C)/(B-A)
     
    OptionsOptionsOptions likes this.
  5. Thanks ,but the formula doesn't work. I came up with a new example and tried keesa's formula.

    A = 124
    B = 970
    X = 124 (input)

    Mapped to:


    C = 0
    D = 100
    Y = 14.66 (output)

    Y output should be 0, but it comes up as 14.66.
     
  6. 2rosy

    2rosy

    standardize your input list from 0 to 1 and then multiply that by
    (max_newrange-min_newrange) +min_newrange

    input_list=124, 345, 654, 784, 970
    std = (input_list - min(input_list)) / ( max(input_list) - min(input_list))
    std *( 10-1 )+1

    output_list mapped from 1 to 10
    1. , 3.35106383, 6.63829787, 8.0212766 , 10.
     
  7. xandman

    xandman

    Y=(X-A)/(B-A) where C,D is 0,100. Change the values of C and D and you have to solve for a system of linear equations.
     
  8. Sekiyo

    Sekiyo

    a0=140; a1=970;
    b0=0; b1=100;

    y=(x-a0)/(a1-a0)*(b1-b0)+b0

    for a0 < x < a1 and b0 < y <b1

    if x= 140 then y= 0
    if x=555 then y = 50
    if x= 970 then y= 100

    Edit: doesn't work yet ... 2s
    Corrected

    a0=140; a1=970;
    b0=100; b1=200;

    if x= 555 then y=150
     
    Last edited: Apr 15, 2020
    ph1l likes this.
  9. ph1l

    ph1l