rect.integrate {BMAmevt} | R Documentation |
Density integration on the two-dimensional simplex
Description
The integral is approximated by a rectangular method, using the values stored in matrix density
.
Usage
rect.integrate(density, npoints, eps)
Arguments
density |
A |
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 |
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
.
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
.
Value
The value of the estimated integral of density
.
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)