SpatEntropy (version 0.1.0)

shannonX: Shannon's entropy.

Description

This function computes Shannon's entropy of a variable \(X\) with a finite number of categories.

Usage

shannonX(data)

Arguments

data

A data matrix or vector, can be numeric, factor, character, ... If the dataset is a point pattern, data is the mark vector.

Value

Estimated probabilities for all data categories, and Shannon's entropy.

Details

Shannon's entropy measures the heterogeneity of a set of categorical data. It is computed as $$H(X)=\sum p(x_i) \log(1/p(x_i))$$ where \(p(x_i)\) is the probability of occurrence of the \(i\)-th category, here estimated by its relative frequency. This is both the non parametric and the maximum likelihood estimator. Shannon's entropy varies between 0 and \(\log(I)\), \(I\) being the number of categories of the variable under study.

Examples

Run this code
# NOT RUN {
#NON SPATIAL DATA
shannonX(sample(1:5, 50, replace=TRUE))

#POINT DATA
data.pp=runifpoint(100, win=square(10))
marks(data.pp)=sample(c("a","b","c"), 100, replace=TRUE)
shannonX(marks(data.pp))

#LATTICE DATA
data.lat=matrix(sample(c("a","b","c"), 100, replace=TRUE), nrow=10)
shannonX(data.lat)

# }

Run the code above in your browser using DataLab