polyCub v0.8.0

0

Monthly downloads

0th

Percentile

Cubature over Polygonal Domains

Numerical integration of continuously differentiable functions f(x,y) over simple closed polygonal domains. The following cubature methods are implemented: product Gauss cubature (Sommariva and Vianello, 2007, <doi:10.1007/s10543-007-0131-2>), the simple two-dimensional midpoint rule (wrapping 'spatstat.geom' functions), adaptive cubature for radially symmetric functions via line integrate() along the polygon boundary (Meyer and Held, 2014, <doi:10.1214/14-AOAS743>, Supplement B), and integration of the bivariate Gaussian density based on polygon triangulation. For simple integration along the axes, the 'cubature' package is more appropriate.

Readme

polyCub

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).

Installation

You can install polyCub from CRAN via:

install.packages("polyCub")

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

## install.packages("remotes")
remotes::install_github("bastistician/polyCub")

Usage

The basic usage is:

library("polyCub")
polyCub(polyregion, f)
  • polyregion represents the integration domain as an object of class "owin" (from spatstat.geom), "gpc.poly" (from gpclib or rgeos), "SpatialPolygons" (from sp), or "(MULTI)POLYGON" (from sf), or even as a plain list of lists of vertex coordinates ("xylist").

  • f is the integrand and needs to take a two-column coordinate matrix as its first argument.

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, https://doi.org/10.1007/s10543-007-0131-2)

  2. polyCub.midpoint(): Simple two-dimensional midpoint rule based on spatstat.geom::as.im.function()

  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, https://doi.org/10.1214/14-AOAS743, 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.

Applications

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.

Feedback

Contributions are welcome! Please submit suggestions or report bugs at https://github.com/bastistician/polyCub/issues or via e-mail to maintainer("polyCub").

License

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

Functions in polyCub

Name Description
plotpolyf Plot Polygonal Domain on Image of Bivariate Function
sfg2gpc Convert polygonal "sfg" to "gpc.poly"
polyCub-package Cubature over Polygonal Domains
polygauss Calculate 2D Nodes and Weights of the Product Gauss Cubature
vecnorm Euclidean Vector Norm (Length)
polyCub.SV Product Gauss Cubature over Polygonal Domains
polyCub.midpoint Two-Dimensional Midpoint Rule
polyCub.iso Cubature of Isotropic Functions over Polygonal Domains
polyCub Wrapper Function for the Various Cubature Methods
xylist Convert Various Polygon Classes to a Simple List of Vertices
polyCub.exact.Gauss Quasi-Exact Cubature of the Bivariate Normal Density
gpclibPermit gpclib License Acceptance
dotprod Dot/Scalar Product of Two Vectors
checkintrfr Check the Integral of \(r f_r(r)\)
isScalar Checks if Argument is Scalar
isClosed Check if Polygon is Closed
circleCub.Gauss Integration of the Isotropic Gaussian Density over Circular Domains
coerce-gpc-methods Conversion between polygonal "owin" and "gpc.poly"
plot_polyregion Plots a Polygonal Domain (of Various Classes)
coerce-sp-methods Coerce "SpatialPolygons" to "owin"
No Results!

Vignettes of polyCub

Name
polyCub.Rmd
No Results!

Last month downloads

Details

Date 2021-01-26
License GPL-2
URL https://github.com/bastistician/polyCub
BugReports https://github.com/bastistician/polyCub/issues
VignetteBuilder knitr, rmarkdown
RoxygenNote 7.1.1
NeedsCompilation yes
Packaged 2021-01-26 18:10:15 UTC; smeyer
Repository CRAN
Date/Publication 2021-01-27 00:30:06 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/polyCub)](http://www.rdocumentation.org/packages/polyCub)