Mapping min and max value to 0.1 and 1 and found equivalent number between

874 Views Asked by At

I'm trying to find a solution for this problem, I have a min and a max value that i want always map as min 0.1 and max 1, so for example:

i have 48 and 97, so 48 will be my 0.1 and 97 will be my 1. Now i want map a number between 0.1 and 1 in the range of 48 and 97. So for example if I have 60 (that is between 48 and 97) what is the mapped 0.1-1 number?

1

There are 1 best solutions below

0
On BEST ANSWER

Use linear interpolation. The function is given by

$$f(x)=0.1+\frac{1-0.1}{\max-\min}(x-\min).$$

Then if $x=\min$ we have $f(x)=0.1$ and if $x=\max$, we have $f(x)=1$. In case $\max=97$, $\min=48$, and $x=60$, we have $f(x)\approx 0.32$.