1

I have the following list of numbers:

3.16, 4.72, 6.44, 8.25, 3.76, 4.87, 5.76, 6.5, 7.32

I have to rescale the numbers between (0, 1) such that:

1)The smallest number gets a value closest to 0 but not 0.

2) The largest number gets a value closest to 1 but not 1.

0 in my study denotes perfectly suitable and 1 denotes perfectly unsuitable, that's why I want to exclude them from the end result.

Any help will be greatly appreciated.

Rahul Rakshit
  • 13
  • 1
  • 3
  • 3
    Which part of this are you having trouble with? – Oliver Charlesworth Aug 29 '11 at 17:39
  • 1
    Do you want a linear or an affine transformation? I.e. `a*x`, or `a*x + b`? – Kerrek SB Aug 29 '11 at 17:40
  • It seems to me that the simplest way to do this is (assigning `max = 8.25`), your value would be something similar to `x' = x / (max + epsilon)` where `x` is your original value (3.16, 4.72), and `x'` the scaled value, and `epsilon` some small nonzero number (so that `max / (max + epsilon) != 1`). Essentially, you would be normalizing your set of data with respect to `max`, which I believe is the definition of rescaling in the way that you want. – mzhang Aug 29 '11 at 17:43
  • Absolutely right. That's what I needed. Thanks a lot for all your kind help. – Rahul Rakshit Aug 29 '11 at 17:51

4 Answers4

2

Would this transform help?

V' = 1/(1 + e^(-V)) -------- Logistic function


Domain - Real numbers so V can take any real values
Range - (0,1) so that, 0<V'<1, V'<>0 and V'<>1

eeerahul
  • 1,629
  • 4
  • 27
  • 38
1

A quick example in Python, using an affine transformation:

 list = [3.16, 4.72, 6.44, 8.25, 3.76, 4.87, 5.76, 6.5, 7.32]

 # find the minimum value and range, and add 1% padding
 range_value = max(list) - min(list)
 range_value = range_value + range_value/50
 min_value = min(list) - range_value/100     

 # subtract the minimum value and divide by the range
 for index, item in enumerate(list):
    list[index] = (item - min_value) / range_value

 print list

Gives the result:

 [0.010000000000000026, 0.310473824107246, 0.64176547632805592, 0.99039215686274518, 0.1255668554258639, 0.33936553796371205, 0.51078970684541003, 0.65332216187064218, 0.81126353095265591]

You can, of course, change the amount of padding to be as small as you'd like - for the range, you'll want to add twice what you do for the minimum value, because you need to add padding to each end of the range.

Hannele
  • 9,301
  • 6
  • 48
  • 68
0

You probably want an affine mapping (i.e. of the form y = mx + c), such that:

not_quite_0 = m*min_val + c
not_quite_1 = m*max_val + c

Solving these equations, you get:

m = (not_quite_1 - not_quite_0) / (max_val - min_val)
c = (max_val*not_quite_0 - min_val*not_quite_1) / (max_val - min_val)

You can probably define not_quite_0 = 0 + eps and not_quite_1 = 1 - eps, where eps is some very very small value.

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
0

I'm not sure I understand your question, but finding the maximum number in the set, and dividing each number in the set by that maximum number will give you a suitable range.

Jon Martin
  • 3,252
  • 5
  • 29
  • 45
  • Using the formula you have stated: 8.25 is the maximum value from the list. I'll get a rescaled value of 1 for 8.25 if I divide each number by the max value. I need the rescaled value of 8.25 to be as near as 1 but not 1 (e.g. 0.99, 0.999, etc.) – Rahul Rakshit Aug 29 '11 at 17:45
  • Yes... so you can use that number to get a suitable range. Of course, your highest number will then be 1, but you can use an epsilon value to fix that. – Jon Martin Aug 29 '11 at 17:46