The **R** package polyCub provides methods for **cubature**
(numerical integration) **over polygonal domains**.
The function `polyCub()`

is the main entry point of the package.
It is a wrapper around the specific cubature methods listed below.

`polyCub.midpoint`

:-
Two-dimensional midpoint rule. Polygons are converted to binary pixel images using the

`as.im.function`

method from package spatstat (Baddeley and Turner, 2005). The integral is then obtained as the sum over (pixel area * f(pixel midpoint)). `polyCub.SV`

:-
Product Gauss cubature as proposed by Sommariva and Vianello (2007).

`polyCub.iso`

:-
Efficient adaptive cubature for

*isotropic*functions via line`integrate()`

along the polygon boundary, see Meyer and Held (2014, Supplement B, Section 2.4). `polyCub.exact.Gauss`

:-
Quasi-exact method specific to the integration of the

*bivariate Gaussian density*over polygonal domains. It is based on formulae from Chapter 26 of the Abramowitz and Stegun (1972) handbook, i.e. triangulation of the polygonal domain (using`tristrip`

of package gpclib) and appropriate evaluations of`pmvnorm`

from package mvtnorm. Note that there is also a function`circleCub.Gauss`

to perform integration of the*isotropic*Gaussian density over*circular domains*.

See Section 3.2 of Meyer (2010) for a more detailed description and benchmark experiment of some of the above cubature methods (and others).

Abramowitz, M. and Stegun, I. A. (1972). Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover Publications.

Baddeley, A. and Turner, R. (2005).
spatstat: an **R** package for analyzing spatial point patterns.
*Journal of Statistical Software*, **12** (6), 1-42.

Meyer, S. (2010). Spatio-Temporal Infectious Disease Epidemiology based on Point Processes. Master's Thesis, LMU Munich. Available as http://epub.ub.uni-muenchen.de/11703/.

Meyer, S. and Held, L. (2014).
Power-law models for infectious disease spread.
*The Annals of Applied Statistics*, **8** (3), 1612-1639.

DOI-Link: http://dx.doi.org/10.1214/14-AOAS743,
arXiv:1308.5115

Sommariva, A. and Vianello, M. (2007).
Product Gauss cubature over polygons based on Green's integration formula.
*Bit Numerical Mathematics*, **47** (2), 441-453.

The packages cubature and R2Cuba, which are more appropriate for cubature over simple hypercubes.

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.