[Math] Bringing numbers in a set closer together

algebra-precalculusaverage

I'm trying to express the relative scale of items compared to an "average" scale for all items in the set. This produces values like { 0.5, 1.8, 0.3, 1.2 … }

I then wish to use this number to visually transform the items so that items that had a smaller relative scale grow somewhat and larger items shrink. Something along the lines of new_size = old_size / scale.

However, this produces too extreme of a transformation. I need to "dampen" this scale value by a controllable amount. So scales < 1.0 would get bigger (but not exceed 1.0) and scales > 1.0 would get smaller (but not be less than 1.0), and an item whose relative scale was 1.0 would remain 1.0.

There must be an easy way to do this, but my math skills are insufficient to the task.

If possible, please express your answer in algorithmic form, since this will be incorporated into a software solution.

Best Answer

You can compute the average of all your numbers, call it $A$. Then given a number $x$ you can adjust its distance from $A$ by scale factor $s$, so $x \to A+s(x-A)$ If you let $s=\frac 23$ the distance from the average will shrink to $\frac 23$ of its previous value. The average will not change.

Related Question