shannon_entropy: Shannon Entropy

Description Usage Arguments Value Examples

View source: R/shannon.R

Description

Compute the base-b Shannon entropy of the distribution p.

Usage

1
shannon_entropy(p, b = 2)

Arguments

p

Dist specifying the distribution.

b

Numeric giving the base of the logarithm.

Value

Numeric giving the Shannon entropy of the distribution.

Examples

1
2
3
4
5
6
7
d <- Dist(c(1, 1, 1, 1))
shannon_entropy(d)          # 2.0
shannon_entropy(d, 4)       # 1.0

d <- Dist(c(2, 1))
shannon_entropy(d)          # 0.9182958
shannon_entropy(d, b = 3)   # 0.5793802

rinform documentation built on April 1, 2018, 12:12 p.m.