R: Plug-In Estimator of the Kullback-Leibler divergence and of...
KL.plugin
R Documentation
Plug-In Estimator of the Kullback-Leibler divergence and of the Chi-Squared Statistic
Description
KL.plugin computes the Kullback-Leiber (KL) divergence from random variable X_1
to X_2. The corresponding probability mass functions are given by freqs1 and freqs2, and the expectation is computed over freqs1.
chi2.plugin computes the chi-squared statistic between an observed X_1 and an expected X_2, where freqs1 and freqs2 are the corresponding probability mass functions.
the unit in which entropy is measured.
The default is "nats" (natural units). For
computing entropy in "bits" set unit="log2".
Details
Kullback-Leibler divergence between the from random variable X_1
to X_2 is given as E_{X_1} log (f(x_1)/f(x_2)) .
The chi-squared statistic is given ∑ (f(x_1)-f(x_2))^2/f(x_2) .
It can also be seen as a second-order accurate
approximation of twice the KL divergence.
Note that both the KL divergence and the chi-squared statistic are not symmetric
in X_1 and X_2.