Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Say for example I have a list of n numbers. I would like to convert this into another list of n numbers which are all within a certain range, e.g. 0 and 1, but still maintain the relationship between the numbers in the original list. So the largest number in the first list would now be 1, the smallest 0, and all the numbers in between would have a value between 0 and 1 corresponding to their relative distance to those extremes.

So if the first list were some values from the function $y = x^2$ and I converted it into this new format and rendered a graph from that, the graph would still have the same shape, but it would be "compressed" to values between 0 and 1 only.

I thought it was called normalization but after Googling I suspect I was wrong. Is there a term for this? Can anyone point me to an algorithm to do this for any input list?

E.g. given the list {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5} I would want something like {0, 0.1, 0.2, 0.3, 0.4, ,0.5, 0.6, 0.7, 0.8, 0.9, 1}

Thanks!

share|improve this question
    
Another applied example is taking a digital color image and converting it to greyscale: you would convert each pixel's color value and convert that to a new value between 0 and 255 (0 = black, 255 = white). –  Danny King Oct 26 '11 at 12:55
1  
"mapping":A rule of correspondence established between sets that associates each element of a set with an element in the same or another set. –  pedja Oct 26 '11 at 13:05
    
"Normalization" sounds fine to me. It means lots of other things too, but I don't see why it couldn't mean this also. –  Henning Makholm Oct 26 '11 at 13:29
    
"Normalization" sounds fine to me, too. If I understood your example correctly, an alternative might be "linearly scaling" or some such. –  Jyrki Lahtonen Oct 26 '11 at 20:30
add comment

1 Answer

up vote 0 down vote accepted

Based on what people have said (thanks!) and subsequent googling I think it is fair to call this normalisation.

For the interested, I found an algorithm to do this. To convert a list of numbers from n to m to be between 0 and 1:

Find the min and the max of the list then for each i: n, ..., m the new value is 2 * (i - min)/( max - min)

(Taken from http://stackoverflow.com/questions/3460905/scale-a-list-of-numbers-to-be-between-1-0-and-1-0)

share|improve this answer
2  
You needn't multiply by 2. The new value is simply $\frac{i - \min}{\max - \min}$. As a check, note that the $\min$ value is mapped to $0$, and the $\max$ value is mapped to $1$. –  Srivatsan Oct 26 '11 at 19:29
    
BTW, Arduino has the map() function to "convert" sensor date from an ADC to other ranges of data. –  Chris K Oct 18 '13 at 8:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.