MyNixOS website logo
Description

Methods for Multivariate Quadrature.

Provides methods to construct multivariate grids, which can be used for multivariate quadrature. This grids can be based on different quadrature rules like Newton-Cotes formulas (trapezoidal-, Simpson's- rule, ...) or Gauss quadrature (Gauss-Hermite, Gauss-Legendre, ...). For the construction of the multidimensional grid the product-rule or the combination- technique can be applied.

mvQuad: Methods for Multivariate Quadrature

link to CRAN: https://cran.r-project.org/web/packages/mvQuad/

This package provides a collection of methods for (potentially) multivariate quadrature in R. It's especially designed for use in statistical problems, characterized by integrals of the form $\int_a^b g(x)p(x) \ dx$, where $p(x)$ denotes a density-function. Furthermore the methods are also applicable to standard integration problems with finite, semi-finite and infinite intervals.

In general quadrature (also named: numerical integration, numerical quadrature) work this way: The integral of interests is approximated by a weighted sum of function values.

$$ I = \int_a^b h(x) \ dx \approx A = \sum_{i=1}^n w_i \cdot h(x_i) $$

The so called nodes ($x_i$) and weights($w_i$) are defined by the chosen quadrature rule, which should be appropriate (better: optimal) for the integration problem in hand^[A rigorous introduction to numerical integration can be found in Davis/Rabinowitz [-@DavisRabinowitz1984]].

This principle can be transferred directly to the multivariate case.

The methods provided in this package cover the following tasks:

  • creating an uni-/multivariate grid (grid: collection of nodes and weights) for a chosen quadrature rule
  • examining the created grid
  • rescaling the grid for appropriate/efficient use
  • computing the approximated integral

Quick Start

This section shows a typical workflow for quadrature with the mvQuad-package. More details and additional features of this package are provided in the subsequent sections. In this illustration the following two-dimensional integral will be approximated: $$ I = \int_1^2 \int_1^2 x \cdot e^y \ dx dy $$

  library(mvQuad)

  # create grid
  nw <- createNIGrid(dim=2, type="GLe", level=6)
  
  # rescale grid for desired domain
  rescale(nw, domain = matrix(c(1, 1, 2, 2), ncol=2))

  # define the integrand
  myFun2d <- function(x){
    x[,1]*exp(x[,2])
  }

  # compute the approximated value of the integral
  A <- quadrature(myFun2d, grid = nw)

Explanation Step-by-Step

  1. mvQuad-package is loaded
  2. with the createNIGrid-command a two-dimensional (dim=2) grid, based on Gauss-Legendre quadrature rule (type="GLe") with a given accuracy level (level=6) is created and stored in the variable nw

The grid created above is designed for the domain $[0, 1]^2$ but we need one for the domain $[1, 2]^2$

  1. the command rescale changes the domain-feature of the grid; the new domain is passed in a matrix (domain=...)

  2. the integrand is defined

  3. the quadrature-command computes the weighted sum of function values as mentioned in the introduction

Supported Rules (build in)

The choice of quadrature rule is heavily related to the integration problem. Especially the domain/support ($[a, b]$ (finite), $[a, \infty)$ (semi-finite), $(-\infty, \infty)$ (infinite)) determines the choice.

The mvQuad-packages provides the following quadrature rules.

  • cNC1, cNC2, ..., cNC6: closed Newton-Cotes Formulas of degree 1-6 (1=trapezoidal-rule; 2=Simpson's-rule; ...), finite domain

  • oNC0, oNC1, ..., oNC3: open Newton-Cote Formula of degree 0-3 (0=midpoint-rule; ...), finite domain

  • GLe, GKr: Gauss-Legendre and Gauss-Kronrod rule, finite domain

  • nLe: nested Gauss-Legendre rule (finite domain) [@Petras2003]

  • Leja: Leja-Points (finite domain)

  • GLa: Gauss-Laguerre rule (semi-finite domain)

  • GHe: Gauss-Hermite rule (infinite domain)

  • nHe: nested Gauss-Hermite rule (infinite domain) [@GenzKeister1996]

  • GHN, nHN: (nested) Gauss-Hermite rule as before but weights are pre-multiplied by the standard normal density ($\hat{w}i = w_i * \phi(x_i)$).^[Those rules are computationally more efficent for integrands of the form: $\int{-\infty}^{\infty} g(x)\phi(x)dx$ because the approximation reduces to $\sum \hat{w}_i \cdot g(x)$.]

For each rule grids can be created of different accuracy. The adjusting screw in the createNIGrid is the level-option. In general, the higher level the more precise the approximation. For the Newton-Cotes rules an arbitrary level can be chosen. The other rules uses lookup-tables for the nodes and weights and are therefore restricted to a maximum level (see help(QuadRules))

Metadata

Version

1.0-8

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows