Description Usage Arguments Details Value References See Also Examples
The function ShannonEntropy
computes the Shannon entropy of a probability vector.
1 |
x |
a numeric probability vector (a vector with non-negative entries summing to one). |
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.
A number.
Fernholz, E. R. (2002) Stochastic portfolio theory. Springer.
EntropyPortfolio
, RelativeEntropy
1 2 | x <- c(1/3, 1/3, 1/3)
ShannonEntropy(x) # equals log(3)
|
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
[1] 1.098612
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.