The goal of kldest
is to estimate Kullback-Leibler (KL) divergence \(D_{KL}(P||Q)\) between two probability distributions \(P\) and \(Q\) based on:
The distributions \(P\) and \(Q\) may be uni- or multivariate, and they may be discrete, continuous or mixed discrete/continuous.
Different estimation algorithms are provided for continuous distributions, either based on nearest neighbour density estimation or kernel density estimation. Confidence intervals for KL divergence can also be computed, either via subsampling (preferred) or bootstrapping.
InstallationYou can install kldest from CRAN:
Alternatively, can install the development version of kldest from GitHub with:
A minimal example for KL divergence estimationKL divergence estimation based on nearest neighbour density estimates is the most flexible approach.
Set a seed for reproducibility
KL divergence between 1-D GaussiansAnalytical KL divergence:
Estimate based on two samples from these Gaussians:
Estimate based on a sample from the first Gaussian and the density of the second:
Uncertainty quantification via subsampling:
KL divergence between 2-D GaussiansAnalytical KL divergence between an uncorrelated and a correlated Gaussian:
Estimate based on two samples from these Gaussians:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4