View source: R/kld-estimation-discrete.R
kld_est_discrete | R Documentation |
Plug-in KL divergence estimator for samples from discrete distributions
kld_est_discrete(X, Y = NULL, q = NULL)
X , Y |
|
q |
The probability mass function of the approximate distribution
|
A scalar, the estimated Kullback-Leibler divergence \hat D_{KL}(P||Q)
.
# 1D example, two samples
X <- c(rep('M',5),rep('F',5))
Y <- c(rep('M',6),rep('F',4))
kld_est_discrete(X, Y)
# 1D example, one sample
X <- c(rep(0,4),rep(1,6))
q <- function(x) dbinom(x, size = 1, prob = 0.5)
kld_est_discrete(X, q = q)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.