Questions tagged [quad]

Quad is a scipy package which is used for 1D integration in Python

135 questions
0
votes
1 answer

Fit data to integral using quad - magnetic hysteresis loop

I'm having trouble getting a fit to converge, as it's either not converging or giving a NaN error, depending on my start parameters. I'm using quad to integrate and fitting using lmfit. Any help is appreciated. I'm fitting my data to a Langevin…
0
votes
1 answer

Problem trying to implement Matlab code in Python

I have a piece of code in Matlab (see below) that works well: clc; clear all; f = 8500; c0 = 343; rho = 1.225; omega = 2*pi*f; k = omega/c0; Z = -426; lx = 0.1; ly = 0.1; nx = 50; ny = nx/2; integrand1 = @(x,y,kx) real(((exp(1i*(kx*x + sqrt(k.^2 -…
0
votes
1 answer

Problem trying to integrate an expression with lambda

I am trying to integrate an expression that has real and complex values defining it as a lambda expression. The integration variable is kx and the resulting solution of the integral will be evaluated in x and y dimensions, but after I integrate and…
0
votes
1 answer

Integration of KDE with strange behavior of from scipy.integrate.quad and the setted bandwith

I was looking for a way to obtaining the mean value (Expected Value) from a drawn distribution that I used to fit a Kernel Density Estimation from scipy.stats.gaussian_kde. I remember from my statistics class that the Expected Value is just the…
Velicious
  • 31
  • 4
0
votes
0 answers

TypeError: only size-1 arrays can be converted to Python scalars when using scipy.integrate.quad

I'm trying to obtain the signal to noise ratio of two variables I have cross-correlated. This involves using scipy.integrate.quad In short, I've got two functions: an integrand and the integral function. The integrand takes four inputs: one array…
Dewy
  • 17
  • 2
0
votes
0 answers

Integral with variable limits (z to 0) in python

I'm trying to compute an integral from z to 0. The same problem has been asked and answered previously here: Integral with variable limits in python However, they integrated from 0 to z. I need to do the same integral, but from z to 0. I followed…
0
votes
2 answers

Are there any inherent limitations to the scipy.integrate.quad function?

I am currently attempting to perform a definite integral of a gaussian function and I am receiving an answer of 0 when I am convinced that is not the case. This leads me to ask, are there limitations on what exactly the quad function can do when…
Peeno
  • 45
  • 4
0
votes
1 answer

Repeated evaluations of integral using scipy integrate.quad

I have a function and I will need to estimate its definite integral over many different intervals, some of them with endpoints quite close to each other, \int_a^{b_k} f(x) dx I could call integrate.quad afresh for each interval, but that would seem…
Galen
  • 13
  • 3
0
votes
1 answer

Evaluating convolution integral using scipy.quad

I have a data set of {x2} values for which two arrays f[x2] and g[x2] are known. The data set {x2} is not uniformly spaced; and I would like to evaluate the convolution integral of f,g using these known samples. A minimal code for this would be…
Zarathustra
  • 391
  • 1
  • 12
0
votes
2 answers

How to fix type 'int' has no len()?

I can't understand what's wrong with this code. Can someone help me please? This is a Pareto type II integrand from 1 to infinite and a and b are the parameters of the distribution. TypeError: object of type 'int' has no len() -> that's the error…
0
votes
1 answer

Scipy quad integral of imaginary numbers

I want to calculate integral of implicit function containing imaginary numbers where f(iz) is something like: and g(ix) is something like: I want to calculate it numerically. Python scipy.quad doesn't calculate integrals of imaginary numbers…
Anna Majewska
  • 23
  • 1
  • 4
0
votes
0 answers

Generate a grid of quads which later can remove individual quad

I'm having trouble coming up with a way to generate a grid of quads. The idea is to later be able to remove a quad at will but didn't even come close to generate the grid. I was thinking of using GL_TRIANGLE primitive but failed at setting up the…
swee
  • 1
  • 1
0
votes
1 answer

Is there a way to integrate the product of two functions numerically in Python?

I have two functions which take multiple arguments: import numpy as np from scipy.integrate import quad gamma_s=0.1 #eV gamma_d=0.1 #eV T=298 #K homo=-5.5 #eV Ef=-5 #eV mu=0 #eV just displaces the function #Fermi-Dirac…
0
votes
1 answer

scipy.optimize.curve_fit ValueError: The truth value of an array with more than one element is ambiguous

I am trying to use scipy.optimize.curve_fit to fit a sigmoidal curve to my dataset but I get the following error: Traceback (most recent call last): File "", line 1, in File…
0
votes
1 answer

Problem with integral calculation integral with OOP in Python

First, i would like to calculate the integral and then i' d like to plot a function F(x) but i have the following error: F() missing 1 required positional argument: 't' import numpy as np import matplotlib.pyplot as plt from scipy.integrate import…
1 2 3
8 9