Description Usage Arguments Value Warning Author(s) See Also Examples
View source: R/StabilityFunctions.R
A function for calculating the Kullback-Leibler divergence between two discrete probability distributions. The vectors specifying the probability distributions must have the same length.
1 | kullback.leibler(p, q)
|
p |
A |
q |
A |
The function returns the Kullback-Leibler divergence between the two specified descrete probability distributions.
The function does not check whether the values in the vectors specifying the discrete probability distributions sum up to one.
Jasmina Bogojeska
L1.dist
, L2.norm
, stability.sim
1 2 3 4 5 6 7 | ## Define two discrete probability distributions with equal lengths.
p <- c(0.1, 0.2, 0.3, 0.4)
q <- c(0.2, 0.5, 0.1, 0.2)
## Calculate the Kullback-Leibler divergence
## between the probability distributions p and q
kullback.leibler(p, q)
|
[1] 0.3542697
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.