Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
x.append(1-e^(-value1^2/2*value2^2))Python 2.7でどのように書くことができますか?
x.append(1-e^(-value1^2/2*value2^2))
べき乗演算子と e の使い方がわかりません。
と同じ数学exp(x)ライブラリの機能を利用できます。したがって、コードを次のように記述できます。e^x
exp(x)
e^x
import math x.append(1 - math.exp( -0.5 * (value1*value2)**2))
1/2asに置き換えて方程式を修正しました0.5。それ以外の Python <2.7の場合、Python は 2 の除算の結果を整数としてfloat丸めるため、除算値を明示的に型キャストする必要があります。int例: Python 2.7 以下で指定します1/2。0
1/2
0.5
float
int
0