entropy: Entropy index

View source: R/describing.R

entropyR Documentation

Entropy index

Description

Calculus of the Shannon's etropy index.

Usage

entropy(x, base = exp(1), inverse = FALSE)

Arguments

x

Numeric vector.

base

Basis of the logarithm.

inverse

Logical specifying if reverse the result by using the inverse function.

Details

When inverse = T, the entropy H is corrected by using the formula: base^H. In this case, the entropy will be included between 1 and the numbers of categories of x.

Examples

x <- c(1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4, 5,5,5,5)
entropy(x, inverse=TRUE)

x <- c(0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3, 4,4,4,4)
entropy(x, inverse=TRUE)

x <- c(1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1)
entropy(x, inverse=TRUE)
entropy(x)

x <- c(1,1,1,1, 1,1,1,1, 4,4,5,5, 5,5,5,5, 5,5,5,5)
entropy(x, inverse=TRUE)
entropy(x)

DavideMassidda/testing documentation built on Oct. 12, 2023, 4:32 p.m.