Description Usage Arguments Details Value Author(s) References Examples
Calculates the Kullback-Leibler divergence for two discrete probability distributions over the same universe.
1 | kullback(target_p, approx_p, log_base = 2)
|
target_p |
Named array with the target distribution. |
approx_p |
Named array with the approximate distribution. |
log_base |
The base used for the logarithm. |
The Kullback-Leibler divergence between two probability distributions p and q is calculated by the formula
D(p||q) = ∑ p(x)log(p(x)/q(x))
where the sum is over all possible states of x.
The Kullback-Leibler divergence.
Katrine Kirkeby, enir_tak@hotmail.com
Maria Knudsen, mariaknudsen@hotmail.dk
Ninna Vihrs, ninnavihrs@hotmail.dk
TCJTtcherry
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | p_target <- array(c(0.1, 0.2, 0.05, 0.4, 0.005, 0.015, 0.13, 0.1),
dim = c(2, 2, 2),
dimnames = list("V1" = c("a", "b"),
"V2" = c("a", "b"),
"V3" = c("a", "b")))
p_approx <- array(c(0.01, 0.23, 0.06, 0.4, 0.005, 0.018,
0.137, 0.14),
dim = c(2, 2, 2),
dimnames = list("V1" = c("a", "b"),
"V2" = c("a", "b"),
"V3" = c("a", "b")))
kullback(p_target, p_approx)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.