Mathematical Integration of a function in Python -
i'm trying integrate function:
however i'm running error of:
traceback (most recent call last): file "<ipython console>", line 1, in <module> file "siestats.py", line 349, in normaldistro p_inner = scipy.integrate(ndfx,-dev,dev) typeerror: 'module' object not callable
my code runs this:
# definition of mathematical function: def ndfx(x): return((1/math.sqrt((2*math.pi)))*(math.e**((-.5)*(x**2)))) # function normailizes x, u, , o2 (position of interest, mean , st dev) # , calculates probability position 'x' def normaldistro(u,o2,x): dev = abs((x-u)/o2) p_inner = scipy.integrate(ndfx,-dev,dev) p_outer = 1 - p_inner p = p_inner + p_outer/2 return(p)
function normaldistro mean import , used this:
foo.normaldistro(30,2.5,1.25)
as example.
the module attempting call scipy.integrate
, need call 1 of functions within module. based on previous comments on chat wanting use scipy.integrate.quad()
.
also, returns tuple of (result,maximumerror)
, shouldn't use p_inner
directly in sum p
, want p = p_inner[0] + p_outer/2
Comments
Post a Comment