The R package polyCub implements cubature (numerical integration) over polygonal domains. It solves the problem of integrating a continuously differentiable function f(x,y) over simple closed polygons.

For the special case of a rectangular domain along the axes, the cubature package is more appropriate (cf. CRAN Task View: Numerical Mathematics).


You can install polyCub from CRAN via:


To install the development version from the GitHub repository, use:

## install.packages("remotes")


The basic usage is:

polyCub(polyregion, f)

The polyCub() function by default calls polyCub.SV(), a C-implementation of product Gauss cubature. The various implemented cubature methods can also be called directly.

Implemented cubature methods

  1. polyCub.SV(): General-purpose product Gauss cubature (Sommariva and Vianello, 2007, BIT Numerical Mathematics,

  2. polyCub.midpoint(): Simple two-dimensional midpoint rule based on

  3. polyCub.iso(): Adaptive cubature for radially symmetric functions via line integrate() along the polygon boundary (Meyer and Held, 2014, The Annals of Applied Statistics,, Supplement B, Section 2.4)

  4. polyCub.exact.Gauss(): Accurate (but slow) integration of the bivariate Gaussian density based on polygon triangulation and mvtnorm::pmvnorm()

For details and illustrations see the vignette("polyCub") in the installed package or on CRAN.


The polyCub package evolved from the need to integrate so-called spatial interaction functions (Gaussian or power-law kernels) over the observation region of a spatio-temporal point process. Such epidemic models are implemented in surveillance.


Contributions are welcome! Please submit suggestions or report bugs at or via e-mail to maintainer("polyCub").


The polyCub package is free and open source software, licensed under the GPLv2.

Try the polyCub package in your browser

Any scripts or data that you put into this service are public.

polyCub documentation built on Jan. 27, 2021, 1:05 a.m.