Jesus, last week’s adventure with general anesthesia must have rotted holes in my brain. I’ve been poking at this simple data transformation for an hour and can’t make it work out. A little help, please and thank you.
Convert range on left to range on right, proportionally.
If I label the entries like a spreadsheet, then A1, A8, B1, and B8 are the relevant input values.
Taking the first row as our “origin”, the scaling factor from one column to the next is (B8-B1)/(A8-A1). To actually scale a given entry, though, I need to subtract out the old offset A1, then scale the number, then add in the new offset. The reason is that the overall offset of the two scales is irrelevant if we just want a linear interpolation between the given entries at rows 1 and 8.
In the end, then, Bn = (An - A1) * (B8 - B1) / (A8 - A1) + B1 .
(I wonder if part of the trouble is that your starting and ending ranges run in opposite directions: low to high becomes high to low. This isn’t a problem for the math, but it could mess with one’s intuition.)
This is a transformation to control cell shading on a graphic; I do this stuff day in and day out and things like an inverted output scale are no hurdle. I just could not seem to find the right model for rescaling the data, even after going at it very slowly a couple of times.
Many thanks. Now I can go back to the couch, where both the puppy and can sleep off the remnants of the fentanyl or whatever the hell it was.