Learn R Programming

ffp (version 0.2.2)

relative_entropy: Relative Entropy

Description

Computes the relative entropy of two distributions.

Usage

relative_entropy(prior, posterior)

Value

A double with the relative entropy.

Arguments

prior

A prior probability distribution.

posterior

A posterior probability distribution.

Examples

Run this code
set.seed(222)

prior <- rep(1 / 100, 100)

posterior <- runif(100)
posterior <- posterior / sum(posterior)

relative_entropy(prior, posterior)

Run the code above in your browser using DataLab