pdf.dist: Distance between densities

Description Usage Arguments Details Value Author(s) Examples

View source: R/pdf.dist.R

Description

Compute the distance between two density functions

Usage

1
pdf.dist(f1, f2, method = c("Hellinger", "abdif"))

Arguments

f1,f2

Two functions of one argument, both of which are densities defined over the whole real line.

method

character; specifying the definition of distance. Current choices are Hellinger and abdif, the latter of which is the integrated absolute differences between the two function.

Details

Numerical integration is performed from -Inf to Inf. Hence, the two functions must be able to accept arguments over the whole real line.

Value

a numeric scalar which is the computed distance, or NA_real_ if any problem occurs.

Author(s)

Long Qu

Examples

1
2
3
4
5
6
# Hellinger distance betwee standard normal and log-normal
pdf.dist(dnorm, dlnorm, 'Hell') # 0.5981035

# absolute difference between standard normal and standard cauchy
f2=function(x)dt(x,1)
pdf.dist(dnorm, f2, 'abd')  #[1] 0.5023312

pi0 documentation built on May 2, 2019, 4:47 p.m.