shannon.Rd
shannon
calculates the Shannon Entropy of a vector. The entropy quantifies the expected value of the information contained in a
vector.
shannon(vec, data = NULL, base = 2)
vec | The vector for which the Shannon Entropy is to be calculated. This is either a vector saved as object or a row of the |
---|---|
data | A data frame object or matrix. |
base | Base of the logarithm to be used, defaults to |
D. Schmitz
### a vector saved as object vector <- runif(50, 0, 10) shannon(vec = vector) #> [1] 5.394103 shannon(vec = vector, base = 10) #> [1] 1.623787 ### a vector specified by its name & its matrix data("gdsm_mat") shannon(vec = "var12", data = gdsm_mat) #> [1] 5.498843 shannon(vec = "var12", data = gdsm_mat, base = 10) #> [1] 1.655317