Marc White
Marc White

Reputation: 41

Rescaling a set of numbers to a new scale

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.

Upvotes: 4

Views: 1500

Answers (1)

loudmummer
loudmummer

Reputation: 554

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.

Upvotes: 4

Related Questions