0
我試圖數值積分正態分佈函數USNG梯形RUL:類型錯誤:「浮動」對象不是可調用/未知的錯誤/無EXP
import math as m
def f(x):
N(x)
return x
def N(x):
x=((2*m.pi)**-(1/2))*m.e(-(1/2)*x**2)
return x
def trap(a, b, n):
h = float(b - a)/n
t = 0.0
for i in range(1, n):
t += f(a + i*h)
t += (f(a)+f(b))/2.0
return t * h
n=int(raw_input("the value of n is:"))
a=int(raw_input("the value of a is:"))
b=int(raw_input("the value of b is:"))
print(trap(a,b,n))
然而,當我嘗試調用
x=((2*m.pi)**-(1/2))*m.e(-(1/2)*x**2)
我得到了以下錯誤線15條,以N:
TypeError: 'float' object is not callable
如果'e'是一個浮動,你想調用它,當你寫的'E( - (1/2)* 2次)' – Carcigenicate