Questions tagged [integral]

This tag should be used for questions related to coding solutions for integrals.

In numerical analysis field, algorithms for integration are a typical example of use for this tag. See also:

819 questions
5
votes
2 answers

Implementing iterative solution of integral equation in Matlab

We have an equation similar to the Fredholm integral equation of second kind. To solve this equation we have been given an iterative solution that is guaranteed to converge for our specific equation. Now our only problem consists in implementing…
Linda
  • 51
  • 1
  • 4
5
votes
1 answer

Efficient implementation of summed area table/integral image in R

I am trying to construct a summed area table or integral image given an image matrix. For those of you who dont know what it is, from wikipedia: A summed area table (also known as an integral image) is a data structure and algorithm for quickly and…
Omar Wagih
  • 8,504
  • 7
  • 59
  • 75
5
votes
1 answer

SymPy - apply limits to an indefinite integral

In SymPy, is it possible to apply limits to an indefinite integral and evaluate it? import sympy from sympy.abc import theta y = sympy.sin(theta) Y_indef = sympy.Integral(y) Y_def = sympy.Integral(y, (theta, 0, sympy.pi / 2)) Y_def.evalf()…
Tim D
  • 1,645
  • 1
  • 25
  • 46
4
votes
0 answers

R: Numerical integration returns a wrong result for a smooth function but does not fail completely

I got a very unlikely, but a very dangerous numerical error while integrating thousands of sufficiently well-behaved functions in R using the built-in integrate function. Story (can be skipped). My problem is connected with maximum likelihood and is…
4
votes
1 answer

triple integral calculation with R

It's my first time on stackoverflow, so please be patient with me! I'm using R-package "pracma" to calculate a triple integral. This is my code: mu1=0 mu2=0 mu3=0 mu4=0 sigma1=1 sigma2=1 sigma3=1 sigma4=1 f3=function(x,y,z){dnorm(z,mean =…
Elena
  • 41
  • 1
4
votes
4 answers

Find midpoints between values in vector

This is for a function to calculate the AUC using the Midpoint Rule. Using R how can I define a vector that contains the midpoints between values of a previous vector? Or how can I shift the values of a vector to their midpoints? # define h (or…
abk
  • 309
  • 6
  • 15
4
votes
2 answers

Integral of dnorm(x, mean=200, sd=20) is not 1

I tried to calculate the integral of the density of the normal distribution with expected value 200 and standard deviation 20. From -Inf to Inf this should be 1. I get the following: > integrate(dnorm, mean=200, sd=20,-Inf, Inf)$value [1]…
Juli Schmitt
  • 41
  • 1
  • 2
4
votes
3 answers

Numpy: vectorizing a function that integrate 2D array

I need to perform this following integration for a 2D array: That is, each point in the grid get the value RC, which is integration over 2D of the difference between the whole field and the value of the field U at certain point (x,y), multiplying…
Ohm
  • 2,312
  • 4
  • 36
  • 75
4
votes
3 answers

Riemann sum of a probability density

I am trying to find the probability of an event of a random variable past a specific value, i.e. pr(x>a), where a is some constant, typically much higher than the average of x, and x is not of any standard Gaussian distribution. So I wanted to fit…
Niklas Lindeke
  • 380
  • 1
  • 7
  • 24
4
votes
2 answers

sympy: how to evaluate integral of absolute value

When I try to simplify the following integral in sympy, it will not evaluate, i.e. the output is $\int_{-1}^1 |z| dz$ while the output I expect is 1. z = symbols('z', real=True) a = integrate(abs(z), (z, -1, 1)) simplify(a) Similar integral without…
Brian
  • 3,453
  • 2
  • 27
  • 39
4
votes
1 answer

Different integration results using Monte Carlo vs scipy.integrate.nquad

The MWE below shows two ways of integrating the same 2D kernel density estimate, obtained for this data using the stats.gaussian_kde() function. The integration is performed for all (x, y) below the threshold point (x1, y1), which defines the upper…
Gabriel
  • 40,504
  • 73
  • 230
  • 404
4
votes
2 answers

Python -the integral from function multiplication

In python, I have two functions f1(x) and f2(x) returning a number. I would like to calculate a definite integral after their multiplication, i.e., something like: scipy.integrate.quad(f1*f2, 0, 1) What is the best way to do it? Is it even possible…
DorianOlympia
  • 841
  • 1
  • 10
  • 22
4
votes
2 answers

Volume of a part of a sphere cutted using 3 planes using R-Language (integral)

I want to calculate the volume (V) of a part of sphere, which is the result of intersetion of the sphere with three palnes (x=0, y=0 and z=1.5). I am using R-Language and this is my code. I tried 2 different methods using cartesian and polar…
4
votes
9 answers

What does 'Conditional expressions can be only boolean, not integral.' mean?

What does 'Conditional expressions can be only boolean, not integral.' mean? I do not know Java and I know C++ deffenetly not enought to understend what it means.. Please help (found in…
Rella
  • 65,003
  • 109
  • 363
  • 636
4
votes
2 answers

Integrate histogram in python?

Is there a simple command in matplotlib that let's me take the integral of histogram over a certain range? If I plot a histogram with: fig = plt.hist(x, bins) Then, is there a command like fig.integral(bin1, bin2)? That will return the integral…
jam
  • 547
  • 4
  • 9
  • 18
1 2
3
54 55