如何将数学公式转换为python代码

问题描述 投票:-1回答:1

How would i convert this into python code?

谢谢。

python-3.x machine-learning linear-regression
1个回答
0
投票

像这样定义它:

import math

def equation(yn, xn, w, T):
    return -yn * xn / (1 + math.exp(yn * xn * w**T))

像这样使用它:

yn = 0.3
xn = 2.1
w = 0.2
T = 1.5

result = equation(yn, xn, w, T)

print(result)
-0.30612739376468273
© www.soinside.com 2019 - 2024. All rights reserved.