integral.density: Compute Integral of One-Dimensional Kernel Density Estimate.

View source: R/unnormdensity.R

integral.densityR 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 x over which the density f(x) should be integrated. A numeric vector of length 2 giving the minimum and maximum values of x. 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 = \int f(x) dx

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

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

is computed, where w 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 x 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

.

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)

spatstat.geom documentation built on Oct. 20, 2023, 9:06 a.m.