Skip to contents

Entropy of a distribution

Usage

entropy(p, base = 2)

Arguments

p

Discrete probability distribution

base

Desired base for entropy, eg, 2 for bits

Value

Calculated Shannon entropy

Examples

entropy(c(0.5, 0.5))
#> [1] 1
entropy(c(0.9, 0.1))
#> [1] 0.4689956