ShannonEntropy: Shannon Entropy

Description Usage Arguments Details Value References See Also Examples

Description

The function ShannonEntropy computes the Shannon entropy of a probability vector.

Usage

1

Arguments

x

a numeric probability vector (a vector with non-negative entries summing to one).

Details

Shannon entropy is a measure of uncertainty. It is maximized when the distribution is uniform, and is zero if it is a point mass. It is used in stochastic portfolio theory as a measure of market diversity. It is also the generating function of the entropy-weighted portfolio (see EntropyPortfolio). See Examples 3.1.2 and 3.4.3 of Fernholz (2002) for more information.

It will be checked whether the input x is reasonably close to a probability vector. If some entries are negative or the sum of the entries is not close enough to 1 (the error margin is 0.01), an error message will be displayed.

Value

A number.

References

Fernholz, E. R. (2002) Stochastic portfolio theory. Springer.

See Also

EntropyPortfolio, RelativeEntropy

Examples

1
2
x <- c(1/3, 1/3, 1/3)
ShannonEntropy(x)  # equals log(3)

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

[1] 1.098612

RelValAnalysis documentation built on May 2, 2019, 3:09 a.m.