# integration.constant: Compute the integration constant for distance density... In Rdistance: Distance-Sampling Analyses for Density and Abundance Estimation

## Description

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

## Usage

 ```1 2``` ```integration.constant(dist, density, a, covars, w.lo, w.hi, series, expansions, pointSurvey) ```

## Arguments

 `dist` Vector of detection distance values. `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` and have the following parameters: a = Parameter vector. dist = Vector of distances. covars = If the density allows covariates, the covariate matrix. w.lo = Lower limit or left truncation value. w.hi = Upper limit or right truncation value. series = Form of the series expansions, if any. expansions = Number of expansion terms. scale = Whether to scale function to integrate to 1. `a` Vector of parameters to pass to `density`. `covars` Matrix of covariate values. `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. `series` The series to use for expansions. If `expansions` > 0, this string specifies the type of expansion. Valid values at present are 'simple', 'hermite', and 'cosine'. `expansions` Number of expansions in `density`. `pointSurvey` Boolean. TRUE if point transect data, FALSE if line transect data.

## Details

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

## Value

A scalar (or vector of scalars if covariates are present) that is the area under `density` between `w.lo` and `w.hi`. This scalar can be used as a divisor to scale density such that it integrates to 1.0. If x = density(...), then x / `integration.constant(density, ...)` will integrate to 1.0.

## Author(s)

Trent McDonald, WEST Inc., tmcdonald@west-inc.com Aidan McDonald, WEST Inc., aidan@mcdcentral.org Michael Kleinsasser, WEST Inc., mkleinsa@uwyo.edu

`dfuncEstim`, `halfnorm.like`
 ``` 1 2 3 4 5 6 7 8 9 10``` ```# Can put any number for first argument (1 used here) scl <- integration.constant(dist=1, density=uniform.like, covars = NULL, pointSurvey = FALSE, w.lo=0, w.hi = 100, expansions = 0, a=c(75,25)) print(scl) # Should be 75.1 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 trapezoid rule, should be 1.0 print(int.y) # Should be 1 ```