开发者

Rescaling numbers between 0 and 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.


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


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜