Skip to contents

$$H(X) = -\sum_x p(x)\log p(x)$$ Shannon (1948), Section 6; Cover & Thomas (2006), eq. (2.1). Counts are accepted as well as probabilities: the input is closed first.

Usage

Shanent(y, base = 2)

Arguments

y

Non-negative probabilities or counts.

base

Log base; 2 gives bits (Shannon's own unit).

Value

Named list with estimate, hmax, evenness, n, method.

References

Shannon (1948), Section 6.

Examples

Shanent(c(1, 1, 1, 1))
#> $estimate
#> [1] 2
#> 
#> $hmax
#> [1] 2
#> 
#> $evenness
#> [1] 1
#> 
#> $n
#> [1] 4
#> 
#> $method
#> [1] "Shannon entropy of a discrete distribution -- Shannon (1948) Sec. 6"
#>