Skip to contents

Shannon entropy for binary vectors

Usage

entropy_bits(v)

Arguments

v

A binary vector

Value

The Shannon entropy of the vector

Details

The probability \(p(1)\) corresponds to the normalized hamming_weight of the vector.

See also

Examples

entropy_bits(c(0, 0, 0))
#> [1] 0
entropy_bits(c(1, 1, 1))
#> [1] 0
entropy_bits(rbits(20))
#> [1] 0.9709506