jsd | R Documentation |
Computes the Jensen-Shannon divergence between two probability distributions.
jsd(p, q, base = c("log", "log2", "log10"), margin = FALSE)
p |
numeric. probability distributions. |
q |
numeric. probability distributions. |
base |
character. log bases. "log", "log2", "log10". default is "log" |
margin |
logical. Choose whether to return individual values or totals. The default value is FALSE, which returns individual values. |
numeric. Jensen-Shannon divergence of probability distributions p and q.
kld
.
# Sample data for probability distributions p.
event <- c(115, 76, 61, 39, 55, 10, 1)
no_event <- c(3, 3, 7, 10, 28, 44, 117)
p <- event / sum(event)
q <- no_event / sum(no_event)
jsd(p, q)
jsd(p, q, base = "log2")
jsd(p, q, margin = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.