Learn R Programming

TreeSearch (version 0.3.2)

Entropy: Entropy in bits

Description

Reports the entropy of a vector of probabilities, in bits. Probabilities should sum to one. Probabilities equalling zero will be ignored.

Usage

Entropy(p)

Arguments

p

Numeric vector specifying probabilities of outcomes.

Value

Entropy of the specified probabilities, in bits

Examples

Run this code
# NOT RUN {
Entropy(rep(0.5, 2)) # = 1
Entropy(c(1/4, 1/4, 0, 1/4, 1/4)) # = 2

# }

Run the code above in your browser using DataLab