numerical-integration

Why does my defined function not accept an array as an input?

Why does my defined function not accept an array as an input? Question: I am working with a double integral, and the inner integral has variable bounds. I wrote a function, using SciPy’s quad integration, that allows me to evaluate this integral. However, what I want is to just evaluate the inner integral, so that …

Total answers: 1

How do I use parameter epsabs in scipy.integrate.quad in Python?

How do I use parameter epsabs in scipy.integrate.quad in Python? Question: I am trying to compute the integrals more precise by specifying the parameter epsabs for scipy.integrate.quad, say we are integrating the function sin(x) / x^2 from 1e-16 to 1.0 from scipy.integrate import quad import numpy integrand = lambda x: numpy.sin(x) / x ** 2 …

Total answers: 1

Integration in case one variable is an array

Integration in case one variable is an array Question: I am trying to do a double integrale, using integrate.dblquad The idea is to pass a function where one of the variables (q) is array: With the numerical integration (for loops over x and y it works, but it is very slow). Scipy gives the following …

Total answers: 1

Pandas integrate over columns per each row

Pandas integrate over columns per each row Question: In a simplified dataframe: import pandas as pd df1 = pd.DataFrame({‘350’: [7.898167, 6.912074, 6.049002, 5.000357, 4.072320], ‘351’: [8.094912, 7.090584, 6.221289, 5.154516, 4.211746], ‘352’: [8.291657, 7.269095, 6.393576, 5.308674, 4.351173], ‘353’: [8.421007, 7.374317, 6.496641, 5.403691, 4.439815], ‘354’: [8.535562, 7.463452, 6.584512, 5.485725, 4.517310], ‘355’: [8.650118, 7.552586, 6.672383, 4.517310, 4.594806]}, index=[1, …

Total answers: 1

Using scipy.integrate.quad to perform 3D integral

Using scipy.integrate.quad to perform 3D integral Question: Motivation for the question I’m trying to integrate a function f(x,y,z) over all space. I have tried using scipy.integrate.tplquad & scipy.integrate.nquad for the integration, but both methods return the integral as 0 (when the integral should be finite). This is because, as the volume of integration increases, the …

Total answers: 2

scipy.integrate.tplquad gives wrong result for integral over large volume

scipy.integrate.tplquad gives wrong result for integral over large volume Question: I’m trying to integrate a function of 3 variables f(x,y,z) over all space. When I integrate over a small volume, I get roughly the right result. However, when I increase the volume of integration, python says that the integral is zero. I’m fairly confident that …

Total answers: 1

scipy integrate.quad return an incorrect value

scipy integrate.quad return an incorrect value Question: i use scipy integrate.quad to calc cdf of normal distribution: def nor(delta, mu, x): return 1 / (math.sqrt(2 * math.pi) * delta) * np.exp(-np.square(x – mu) / (2 * np.square(delta))) delta = 0.1 mu = 0 t = np.arange(4.0, 10.0, 1) nor_int = lambda t: integrate.quad(lambda x: nor(delta, …

Total answers: 1