Learn R Programming

Rdistance (version 1.2.2)

integration.constant: Compute the integration constance for distance density functions.

Description

Using numerical integration, compute the area under a given distance function between two limits (w.lo and w.hi).

Usage

integration.constant(density, w.lo, w.hi, ...)

Arguments

density
A likelihood function for which the integration constant is sought. This function must be capable of evaluating values between w.lo and w.hi. This function must have the following parameters:
  • a
w.lo
The lower limit of integration, or the left truncation value for perpendicular distances.
w.hi
The upper limit of integration, or the right truncation value for perpendicular distances.
...
Additional parameters to the likelihood function density.

Value

  • A scalar that is the area under density between w.lo and w.hi. This scalar can be used as divisor to scale density such that it integrates to 1.0. If x = density(...), then x / integration.constant(density, ...) will integrate to 1.0.

Details

The trapazoid rule is used to numerically integrate density from w.lo to w.hi. Two-hundred (200) trapazoids are used in the integration. The number of trapazoids to use is fixed and cannot be changed without re-writing the routine.

See Also

F.dfunc.estim, halfnorm.like

Examples

Run this code
#   The following result should be approximately 75
scl <- integration.constant(uniform.like, w.lo=0, w.hi=100, a=c(75,25))
print(scl)

#   Check that likelihood / scl integrates to 1.0
x <- seq(0,100,length=200)
y <- uniform.like( c(75,25), x, scale=FALSE ) / scl
int.y <- (x[2]-x[1]) * sum(y[-length(y)]+y[-1]) / 2  # the trapazoid rule, should be 1.0
print(int.y)

Run the code above in your browser using DataLab