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 |
domain |
Optional. Range of values of the argument |
weight |
Optional. A |
... |
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 Baddeley Adrian.Baddeley@curtin.edu.au.
See Also
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)