Learn R Programming

exPrior (version 1.0.1)

KL_divergence: Kullback-Leibler divergence

Description

KL_divergence calculates the Kullback-Leibler divergence

Usage

KL_divergence(theta, p_theta, q_theta)

Arguments

theta

a vector of numerics containing values of the RV \(\theta\)

p_theta

a vector of numerics containing values of the pdf p at locations theta

q_theta

a vector of numerics containing values of the pdf q at locations theta

Value

The Kullback-Leibler divergence from q to p

Examples

Run this code
# NOT RUN {
theta=seq(from=-5,to=5,by=0.1)
p_theta = dnorm(theta,mean = 0.2,sd = 1)
q_theta = dnorm(theta,mean = 0.25,sd = 0.5)

# }

Run the code above in your browser using DataLab