scale a number between a range I have been trying to achieve a system which can scale a number down and in between two ranges. I have been stuck with the mathematical part of it.
What im thinking is lets say number 200 to be normalized so it falls between a range lets say  0 to 0.66 or 0.66 to 1 or 1 to 1.66. The range being variable as well.
Any help would be appreciated.
Thanks
 A: In general, to scale your variable $x$ into a range $[a,b]$ you can use:
$$
x_{normalized} = (b-a)\frac{x - min(x)}{max(x) - min(x)} + a
$$
A: Your scaling will need to take into account the possible range of the original number. There is a difference if your 200 could have been in the range [200,201] or in [0,200] or in [0,10000].
So let 


*

*$r_{\text{min}}$ denote the minimum of the range of your measurement

*$r_{\text{max}}$ denote the maximum of the range of your measurement

*$t_{\text{min}}$ denote the minimum of the range of your desired target scaling

*$t_{\text{max}}$ denote the maximum of the range of your desired target scaling

*$m\in[r_{\text{min}},r_{\text{max}}]$ denote your measurement to be scaled


Then
$$ m\mapsto \frac{m-r_{\text{min}}}{r_{\text{max}}-r_{\text{min}}}\times (t_{\text{max}}-t_{\text{min}}) + t_{\text{min}}$$
will scale $m$ linearly into $[t_{\text{min}},t_{\text{max}}]$ as desired.
To go step by step,


*

*$ m\mapsto m-r_{\text{min}}$ maps $m$ to $[0,r_{\text{max}}-r_{\text{min}}]$.

*Next,
$$ m\mapsto \frac{m-r_{\text{min}}}{r_{\text{max}}-r_{\text{min}}} $$
maps $m$ to the interval $[0,1]$, with $m=r_{\text{min}}$ mapped to $0$ and $m=r_{\text{max}}$ mapped to $1$.

*Multiplying this by $(t_{\text{max}}-t_{\text{min}})$ maps $m$ to $[0,t_{\text{max}}-t_{\text{min}}]$.

*Finally, adding $t_{\text{min}}$ shifts everything and maps $m$ to $[t_{\text{min}},t_{\text{max}}]$ as desired.
