Learn R Programming

PoolBal (version 0.1-0)

klDiv: Compute the Kullback-Leibler divergence

Description

Computes the Kullback-Leibler divergence for two arbitrary densities f1 and f2.

Usage

klDiv(f1, f2, lower = 0, upper = 1)

Value

A real value.

Arguments

f1

density function of a real-valued random variable

f2

density function of a real-values random variable

lower

real value, the lower bound of integration

upper

real value, the upper bound of integration

Author

Chris Salahub

Details

Given lower and upper bounds, this function integrates the expression for the Kullback-Leibler divergence KL(f1|f2).

Examples

Run this code
klDiv(dunif, function(x) dbeta(x, 0.5, 1))

Run the code above in your browser using DataLab