shannon: Calculate Shannon Entropy

shannonR Documentation

Calculate Shannon Entropy

Description

shannon calculates the Shannon Entropy of a vector. The entropy quantifies the expected value of the information contained in a vector.

Usage

shannon(vec, data = NULL, base = 2)

Arguments

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 neighbors data frame or matrix. If a row of a data frame or matrix is specified, this row is excluded as competitor for the nearest neighbor (as a row will be closest to itself).

data

A data frame object or matrix.

base

Base of the logarithm to be used, defaults to 2.

Author(s)

D. Schmitz

Examples


### a vector saved as object

vector <- runif(50, 0, 10)

shannon(vec = vector)

shannon(vec = vector, base = 10)


### a vector specified by its name & its matrix

data("gdsm_mat")

shannon(vec = "var12", data = gdsm_mat)

shannon(vec = "var12", data = gdsm_mat, base = 10)


dosc91/gdsm documentation built on Aug. 21, 2022, 4:16 a.m.