integral.density {spatstat.univar}R Documentation

Compute Integral of One-Dimensional Kernel Density Estimate.

Description

Compute the integral of a kernel density estimate over a specified range.

Usage

## S3 method for class 'density'
integral(f, domain = NULL, weight=NULL, ...)

Arguments

f

A one-dimensional probability density estimate (object of class "density") obtained from the function density.default or from unnormdensity.

domain

Optional. Range of values of the argument xx over which the density f(x)f(x) should be integrated. A numeric vector of length 2 giving the minimum and maximum values of xx. Infinite limits are permitted.

weight

Optional. A function(x) specifying a weight integrand.

...

Ignored.

Details

This is a method for the generic function integral. It computes the numerical integral

I=f(x)dx I = \int f(x) dx

of the density estimate f. If weight is specified, then the weighted integral

I=w(x)f(x)dx I = \int w(x) f(x) dx

is computed, where ww is the function specified by weight. This function must return finite numerical values.

If domain is specified, the integral is restricted to the interval of xx values given by the domain.

Integrals are calculated numerically using the trapezoidal rule restricted to the domain given.

Value

A single numerical value.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au.

See Also

density.default

quantile.density, CDF.density

Examples

  x <- runif(10)
  d <- density(x, bw=0.1)
  integral(d) # should be approximately 1
  integral(d, domain=c(-Inf, 0)) # mass on negative half-line
  ## mean of density
  integral(d, weight=function(x) x)

[Package spatstat.univar version 3.0-0 Index]