2016-11-13 57 views
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

+1

如果'e'是一個浮動,你想調用它,當你寫的'E( - (1/2)* 2次)' – Carcigenicate

回答

0

math.e是常數2.71 ...這是一個浮動不是可調用的。指數函數是math.exp

相關問題