rect.integrate function

Density integration on the two-dimensional simplex

Density integration on the two-dimensional simplex

The integral is approximated by a rectangular method, using the values stored in matrix density.

rect.integrate(density, npoints, eps)

Arguments

  • density: A npoints*npoints matrix containing the density's values scattered on the discretization grid defined by npoints, equi, eps (see discretize).
  • npoints: The number of grid nodes on the squared grid containing the desired triangle.
  • eps: Positive number: minimum distance from any node inside the simplex to the simplex boundary

Returns

The value of the estimated integral of density.

Details

Integration is made with respect to the Lebesgue measure on the projection of the simplex onto the plane (x,y):x>0,y>0,x+y<1(x,y): x > 0, y > 0, x+y < 1. It is assumed that density has been constructed on a grid obtained via function discretize, with argument equi set to FALSE and npoints

and eps equal to those passed to rect.integrate.

Examples

wrapper <- function(x, y, my.fun,...) { sapply(seq_along(x), FUN = function(i) my.fun(x[i], y[i],...)) } grid <- discretize(npoints=40,eps=1e-3,equi=FALSE) Density <- outer(grid$X,grid$Y,FUN=wrapper, my.fun=function(x,y){10*((x/2)^2+y^2)}) rect.integrate(Density,npoints=40,eps=1e-3)
  • Maintainer: Leo Belzile
  • License: GPL (>= 2)
  • Last published: 2023-04-21

Useful links