entropy {partitionComparison} | R Documentation |
Entropy
Description
Compute the Shannon entropy
Usage
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))
Arguments
x |
A probability distribution |
log_base |
Optional base of the logarithm (default: |
Methods (by class)
-
entropy(x = Partition, log_base = numeric)
: Entropy of a partition represented byx
Hint
This method is used internally for measures based on information theory
Author(s)
Fabian Ball fabian.ball@kit.edu
Examples
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))))
[Package partitionComparison version 0.2.6 Index]