Calculate distribution overlap by KDE (Kernel Density Estimation) This function compares two estimated distributions by KDE method. It utilizes base density function in R.

ovl_kde(x1, x2, n = 1024)

Arguments

x1

A numeric vector.

x2

A numeric vector.

n

An integer. Number of bins in KDE.

Value

estimated overlap between two distributions (range: 0 to 1)

References

This code is adopted from overlapping package (paper) and modified by Seongyong Park. You can find original implementation in overlapping R package. (github)

See also

Author

Seongyong Park (2020-08-18)

Examples

x1 = rnorm(100, 0) x2 = rnorm(100, 1) ovl_kde(x1, x2, n=1024)
#> [1] 0.3554536