Edit:
I made a mistake or someone did. The a and b and max and min is swapped in the formula I used. Upon switching the a for min and b for max, the algorithm worked as I expected.
Previously I had
a = -180, b= 180, and then min -100, max = 100
instead it should've been
a = -100, b= 100, and then min -180, max = 180
And based on the answer below, I figured out that the x is the series I'm working with.
After that it was just matter of pulling the (x-min) out of the fraction to make it easier to realize what to do next.
$$f(x)=(x - min)\frac{(b-a)}{max - min} + {a}$$
Since x was my series, all I had to do with subtract min (the right number this time), and then the rest was just simple routine.
I posted this in a wrong group, but I think this is more of a simple math problem, which I jut can't wrap my mind around.
Let's say you have 2 lists of real numbers.
list_1 ranges from -100 to 100 over time.
list_2 ranges from -80 to 80 over time. (exact same time as list_1)
And then I have a third list, which is a sum of the list_1 and list_2, (let's call it list_sum) thus can range from -180 to 180.
I would like to come up with a formula to scale the sum of the lists, list_sum, to the min and max of either list_1 or list_2.
So basically, I'm trying to come up with
list_sum * factor
or
function(list_sum)
that should give me the list_sum's min and max to be within the range of list_1 or list_2.
It's gotta be related to (based on some search i've done)
$$f(x) = \frac{(b-a)(x - min)}{max - min} + {a}$$
How so?
If given the list_sum (gives me min and max of my list) and list_1 (gives me a and b of the scale) to be scaled to,
a = -100, b= 100, and then min -180, max = 180
that gives me
$$\frac{(100-(-100))(x - (-180))}{180- (-180)} + {-100}$$
or
$$\frac{(200)(x + 180)}{360} {-100}$$
Does that seems right to anyone?
if so, how do I use that if my list_sum is to be transformed?
Thanks for the help.