Normalize numerical values

50 Views Asked by At

In a AI course, we have to normalize a set of numerical inputs such that the highest input becomes $1$ and the lowest becomes $0$. The set is as follows:

$ 1\\3\\5\\2 $

So the first entry should become $0$ and the third one becomes $1$. Now how do I calculate the second and last one? I can't just divide by 5 because dividing one by five would give $0.2$ and not $0$.

2

There are 2 best solutions below

0
On BEST ANSWER

You just need the following formula: $$\frac{x-min}{max-min}$$ Which $min$ and $max$ are the minimum and maximum value in data which is $1$ and $5$ here, respectively.

0
On

You want to map all the values you have to the interval $[0,1]$ -- that's what's meant by normalise. So, if $A = \{1,3,5,2\}$ is your set of values, you need the width of $A$, i.e. $$ w(a) := \max_{x \in A} x - \min{x\in A} x $$

Then you need to rebase $A$ to have zero in it. This can be done by subtracting the minimum element from the set. So for each element in the set $A$ you translate and then divide by the width, i.e.

$$ x \mapsto \frac{x-\min_{y\in A} y}{w(A)} $$