How to adjust a data set so that the differences are smaller?

33 Views Asked by At

I have data that is 100 values long. Each value is between 0.8 and 1. I want to adjust the values so that the maximum value in the data is 1 and minimum is 0.9 instead. How do i do this?

Thanks Bobby

2

There are 2 best solutions below

0
On

Your maximum is where you want already (I think). You want to compress things so the range is half of what it was.

One way is to calculate the difference of each point from $1$, halve it, and then add it back to $1$. So, for $0.8$, the difference from $1$ is $-0.2$, half of which is $-0.1$, added back is $0.9$. For $0.95$, the difference is $-0.05$ half of which is $-0.025$, added back is $0.975$.

This keeps the relative distribution of the points the same, but compresses them.

0
On

In general, if you want to map invertal $[a,b]$ to interval $[A,B]$, you have to get a factor $f$ of dilation or contraction. This is naturally based on interval length: $$f = \frac{B-A}{b-a}\,.$$

For a linear mapping, you may want that $x$ close to $a$ is mapped close to $A$, but proportionnaly to the dilation factor $f$. Now look at $f(x-a)$ when $x$ is close to $a$? It is close to $0$, so you need to add $A$. Now we have:

$$m(x) = \frac{B-A}{b-a}(x-a)+A\,.$$

If we did stuff correctly, we should now have $m(b)= (B-A)+A=B$. Hurray!

This is the formula by @jibounet, put in words by @John, resulting in:

$$m(x) = \left(\frac{1-x}{2} \right)+x\,.$$

This mapping is illustrated as below:

Companding based on a linear function

Now you can do more fancy stuff. Maybe you want to compress more values near $1$, and less near $0.9$. So you can use a (non-linear) function $g$ on $[0.8,1]$ that takes its extremum values say at $x_m$ and $x_M$. Then another formula could be:

$$m(x) = \frac{0.1}{f(x_M)-f(x_m)}(f(x)-f(x_m))+0.9\,.$$

This is a (non-linear) companding method, which was used in telecommunations, to reducing artifacts when sending data over a limited range of values.

With a square root function, you can get pictures like:

Companding based on a square root