Math 带自定义范围的Sigmoid缩放和反转

Math 带自定义范围的Sigmoid缩放和反转,math,inverse,sigmoid,Math,Inverse,Sigmoid,我让大脑思考如何使用Sigmoid在自定义范围内缩放变量,然后反向缩放 import math # apply Sigmoid to x on scale between 0 and top: def sigmoid(x, top): y = top / (1 + math.exp(-x)) return y # and to inverse: def invSigmoid(y, top): x = np.log(y/(top-y)) return x 例如

我让大脑思考如何使用Sigmoid在自定义范围内缩放变量,然后反向缩放

import math

# apply Sigmoid to x on scale between 0 and top:
def sigmoid(x, top):
    y = top / (1 + math.exp(-x))
    return y

# and to inverse:
def invSigmoid(y, top):
    x = np.log(y/(top-y))
    return x
例如,下面的Python脚本在0和顶部之间缩放变量x,然后反转该缩放

import math

# apply Sigmoid to x on scale between 0 and top:
def sigmoid(x, top):
    y = top / (1 + math.exp(-x))
    return y

# and to inverse:
def invSigmoid(y, top):
    x = np.log(y/(top-y))
    return x

我想做的是设置底部,以便x在底部和顶部之间缩放,例如(10-100)。然后也得到相反的结果。

在我看来,你想要的是:

y = bottom + (top - bottom) / (1 + math.exp(-x))