3

I am trying to rescale a set of numbers to a new scale with some specific requirements.

Imagine I have a set of numbers between 1-100

I want to be able to scale this set of numbers to a new scale between 80 - 120 where 80 is the min of the original set, 120 is the max of the original set and 100 is the mean.

To use a small example:

For the set [43,26,56,21,25,94]

On the new scale 21 would map to 80, 94 would map to 120, and 44.2 would map to 100.

Marc White
  • 31
  • 1
  • Possible duplicate of [How to scale down a range of numbers with a known min and max value](https://stackoverflow.com/questions/5294955/how-to-scale-down-a-range-of-numbers-with-a-known-min-and-max-value) – GalAbra Jun 05 '18 at 09:13
  • What language are you doing it in, and what have you tried? Are you restricted to integers, or would you want floating point calculations? – Dragonthoughts Jun 05 '18 at 09:38

1 Answers1

3

The map f that scales a range [a b] to [c d] is f(x) = (x-a)*(d-c)/(b-a) + c

However, I don't think it is possible to ensure a linear f also maps the mean of arbitrary values in a set contained in the range [a b] to a specified value in the range [c d] (including the average of c and d).

For that, you will have to either scale [a mean] to [c (c+d)/2)] and [mean b] to [(c+d)/2 d] separately, or use some other non-linear mapping.

loudmummer
  • 544
  • 3
  • 19