kld_est_discrete {kldest} | R Documentation |
Plug-in KL divergence estimator for samples from discrete distributions
Description
Plug-in KL divergence estimator for samples from discrete distributions
Usage
kld_est_discrete(X, Y = NULL, q = NULL)
Arguments
X , Y |
|
q |
The probability mass function of the approximate distribution
|
Value
A scalar, the estimated Kullback-Leibler divergence \hat D_{KL}(P||Q)
.
Examples
# 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)
[Package kldest version 1.0.0 Index]