View source: R/kld-analytical.R
kld_discrete | R Documentation |
Analytical KL divergence for two discrete distributions
kld_discrete(P, Q)
P , Q |
Numerical arrays with the same dimensions, representing discrete probability distributions |
A scalar (the Kullback-Leibler divergence)
# 1-D example
P <- 1:4/10
Q <- rep(0.25,4)
kld_discrete(P,Q)
# The above example in 2-D
P <- matrix(1:4/10,nrow=2)
Q <- matrix(0.25,nrow=2,ncol=2)
kld_discrete(P,Q)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.