Learn R Programming

TreeDist (version 2.10.1)

Entropy: Entropy in bits

Description

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

Usage

Entropy(...)

Ntropy(...)

Value

Entropy() and Ntropy() return the entropy of the specified probabilities or counts, in bits.

Arguments

...

Series of numerics, or single numeric vector, specifying probabilities of outcomes (for Entropy()) or counts (for Ntropy()).

Examples

Run this code
Entropy(1/2, 0, 1/2) # = 1
Entropy(rep(1/4, 4)) # = 2
Ntropy(c(2, 2, 0, 2, 2)) # = 2

Run the code above in your browser using DataLab