overlap: Overlap of two probability density functions

Description Usage Arguments Details Value See Also Examples

Description

Calculate overlap of two probability density functions as their intersection. Can compare two 'niche' distributions.

Usage

1
overlap(a, b, buff = 0.05, na.rm = TRUE, ...)

Arguments

a

first vector of values

b

second vector of values, potentially of different length than a

buff

multiplier for buffer at tail ends, expressed as proportion of total data range; default is 0.05

na.rm

logical, remove NA values? Default is na.rm = TRUE.

...

further arguments passed to additional methods

Details

Overlap is calculated as two times the area under the intersection, divided by total area under both curves

Value

Numeric value for coefficient of overlap

See Also

https://stats.stackexchange.com/questions/97596/

Examples

1
2
3
4
5
6
7
8
set.seed(122)
N <- 999
x1 <- rnorm(N)
x2 <- rnorm(N+99, 2) # lengths allowed to differ
plot(density(x1, from=-5, to=5), xlab='x', main='', las=1, bty='l')
lines(density(x2, from=-5, to=5), lty=2)
overlap(x1,x2)
text(1, .1, round(overlap(x1,x2),2))

phytomosaic/ecole documentation built on Dec. 7, 2018, 6:06 p.m.