我有以下数字列表:
3.16、4.72、6.44、8.25、3.76、4.87、5.76、6.5、7.32
我必须重新调整 (0, 1) 之间的数字,以便:
1) 最小的数得到最接近 0 但不是 0 的值。
2) 最大的数得到最接近 1 但不是 1 的值。
在我的研究中,0 表示完全合适,1 表示完全不合适,这就是为什么我想将它们排除在最终结果之外。
任何帮助将不胜感激。
我有以下数字列表:
3.16、4.72、6.44、8.25、3.76、4.87、5.76、6.5、7.32
我必须重新调整 (0, 1) 之间的数字,以便:
1) 最小的数得到最接近 0 但不是 0 的值。
2) 最大的数得到最接近 1 但不是 1 的值。
在我的研究中,0 表示完全合适,1 表示完全不合适,这就是为什么我想将它们排除在最终结果之外。
任何帮助将不胜感激。
这种转变会有帮助吗?
V' = 1/(1 + e^(-V)) -------- Logistic function
域 - 实数,因此V
可以采用任何实数值
Range - (0,1)
,因此 0<V'<1
,V'<>0
和V'<>1
Python 中的一个简单示例,使用仿射变换:
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
给出结果:
[0.010000000000000026, 0.310473824107246, 0.64176547632805592, 0.99039215686274518, 0.1255668554258639, 0.33936553796371205, 0.51078970684541003, 0.65332216187064218, 0.81126353095265591]
当然,您可以根据需要将填充量更改为尽可能小 - 对于范围,您需要将最小值添加两倍,因为您需要在每个末端添加填充范围。
你可能想要一个仿射映射(即形式y = mx + c
),这样:
not_quite_0 = m*min_val + c
not_quite_1 = m*max_val + c
解这些方程,你得到:
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)
您可能可以定义not_quite_0 = 0 + eps
and not_quite_1 = 1 - eps
,其中eps
是一些非常小的值。
我不确定我是否理解您的问题,但是找到集合中的最大数字,并将集合中的每个数字除以该最大数字将为您提供合适的范围。