Description Usage Arguments Details Value Author(s) See Also Examples
entropy
estimates the Shannon entropy H of the random variable Y
from the corresponding observed counts y
.
freqs
estimates bin frequencies from the counts y
.
1 2 3 4 |
y |
vector of counts. |
method |
the method employed to estimate entropy (see Details). |
unit |
the unit in which entropy is measured.
The default is "nats" (natural units). For
computing entropy in "bits" set |
lambda.freqs |
shrinkage intensity (for "shrink" option). |
verbose |
verbose option (for "shrink" option). |
... |
option passed on to |
The entropy
function allows to estimate entropy from observed counts by a variety
of methods:
method="ML"
:maximum likelihood, see entropy.empirical
method="MM"
:bias-corrected maximum likelihood, see entropy.MillerMadow
method="Jeffreys"
:entropy.Dirichlet
with a=1/2
method="Laplace"
:entropy.Dirichlet
with a=1
method="SG"
:entropy.Dirichlet
with a=a=1/length(y)
method="minimax"
:entropy.Dirichlet
with a=sqrt(sum(y))/length(y
method="CS"
:see entropy.ChaoShen
method="NSB"
:see entropy.NSB
method="shrink"
:see entropy.shrink
The freqs
function estimates the underlying bin frequencies. Note that
estimated frequencies are not
available for method="MM"
, method="CS"
and method="NSB"
. In these
instances a vector containing NAs is returned.
entropy
returns an estimate of the Shannon entropy.
freqs
returns a vector with estimated bin frequencies (if available).
Korbinian Strimmer (https://strimmerlab.github.io).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # load entropy library
library("entropy")
# observed counts for each bin
y = c(4, 2, 3, 0, 2, 4, 0, 0, 2, 1, 1)
entropy(y, method="ML")
entropy(y, method="MM")
entropy(y, method="Jeffreys")
entropy(y, method="Laplace")
entropy(y, method="SG")
entropy(y, method="minimax")
entropy(y, method="CS")
#entropy(y, method="NSB")
entropy(y, method="shrink")
|
[1] 1.968382
[1] 2.152593
[1] 2.17948
[1] 2.257876
[1] 2.036888
[1] 2.154091
[1] 2.201137
Estimating optimal shrinkage intensity lambda.freq (frequencies): 0.7664
[1] 2.379603
attr(,"lambda.freqs")
[1] 0.7663934
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.