# Small Data transformation: need answer quickish

**URL:** <https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893>\
**Category:** Factual Questions\
**Created:** [March 10, 2017, 6:37pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893 "2017-03-10T18:37:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amateur\_Barbarian](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Amateur\_Barbarian](https://boards.straightdope.com/u/Amateur_Barbarian)\
**Post date:** [March 10, 2017, 6:37pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893/1 "2017-03-10T18:37:42Z")

</div>

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.

```
    20.425 80.000

```

20.983  
22.674  
22.697  
23.667  
24.440  
24.555  
24.631 40.000

This is very mildly for commercial purposes, but not “homework.” Thanks. Payment in wooden nickels available.

---

<div class="post-metadata">

**Author:** ![Pasta](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pasta](https://boards.straightdope.com/u/Pasta)\
**Post date:** [March 10, 2017, 6:58pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893/2 "2017-03-10T18:58:05Z")

</div>

I think you’re after this?

```auto

20.425	80	80
20.983 74.69329529
22.674 58.61150737
22.697 58.39277223
23.667 49.16785544
24.44 41.81645269
24.555 40.72277699
24.631	40	40

```

---

<div class="post-metadata">

**Author:** ![Amateur\_Barbarian](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Amateur\_Barbarian](https://boards.straightdope.com/u/Amateur_Barbarian)\
**Post date:** [March 10, 2017, 7:06pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893/3 "2017-03-10T19:06:31Z")

</div>

> [@Pasta](#):
>
> I think you’re after this?
> 
> ```auto
> 
> 20.425 80 80
> 20.983 74.69329529
> 22.674 58.61150737
> 22.697 58.39277223
> 23.667 49.16785544
> 24.44 41.81645269
> 24.555 40.72277699
> 24.631 40 40
> 
> ```

Someday you’ll have to show me how you did that. I useta know, back when I had brain cells.

Thanks. PM me if you need anything in a graphics/publications/online etc. vein.

---

<div class="post-metadata">

**Author:** ![Pasta](https://avatars.discourse-cdn.com/v4/letter/p/ecccb3/32.png) [@Pasta](https://boards.straightdope.com/u/Pasta)\
**Post date:** [March 10, 2017, 7:26pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893/4 "2017-03-10T19:26:47Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![Amateur\_Barbarian](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@Amateur\_Barbarian](https://boards.straightdope.com/u/Amateur_Barbarian)\
**Post date:** [March 10, 2017, 7:29pm UTC](https://boards.straightdope.com/t/small-data-transformation-need-answer-quickish/781893/5 "2017-03-10T19:29:18Z")

</div>

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.
