entropy {eHDPrep} | R Documentation |
Calculate Entropy of a Vector
Description
Calculates Shannon Entropy of a vector in bits (default) or natural units. Missing values are omitted from the calculation.
Usage
entropy(x, unit = c("bits"))
Arguments
x |
Input vector |
unit |
Unit to measure entropy. Either "bits" (default) or "nats". |
Value
Entropy of input variable
References
Shannon, C. E. A mathematical theory of communication. The Bell System Technical Journal 27, 379–423 (1948).
Examples
# no entropy:
vec <- c(1,1,1,1,1,1)
entropy(vec)
# entropy
vec <- c(1,2,3,4,5,6)
entropy(vec)
[Package eHDPrep version 1.3.3 Index]