entropy | R Documentation |
Compute the Shannon entropy
-\sum_{i} p_i \log_b p_i
entropy(x, log_base)
## S4 method for signature 'numeric,numeric'
entropy(x, log_base)
## S4 method for signature 'Partition,numeric'
entropy(x, log_base)
## S4 method for signature 'ANY,missing'
entropy(x, log_base = exp(1))
x |
A probability distribution |
log_base |
Optional base of the logarithm (default: |
entropy(x = Partition, log_base = numeric)
: Entropy of a partition represented by x
This method is used internally for measures based on information theory
Fabian Ball fabian.ball@kit.edu
isTRUE(all.equal(entropy(c(.5, .5)), log(2)))
isTRUE(all.equal(entropy(c(.5, .5), 2), 1))
isTRUE(all.equal(entropy(c(.5, .5), 4), .5))
# Entropy of a partition
isTRUE(all.equal(entropy(new("Partition", c(0, 0, 1, 1, 1))), entropy(c(2/5, 3/5))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.