Diversity Indices
Diversity indices summarize one assemblage at a time. In DiversityAndDissimilarity.jl, use entropy when you want entropy units and diversity or effective_diversity when you want diversity-scale values.
julia> using DiversityAndDissimilarity
julia> assemblage = Dict(:oak => 12, :ash => 5, :elm => 3);
julia> diversity(Richness(), assemblage)
3
julia> entropy(Shannon(), assemblage)
1.3527241956246545
julia> diversity(Shannon(), assemblage)
2.5539392274300625Available Methods
| Family | Types and helpers | Main options | Typical use |
|---|---|---|---|
| Richness | Richness, richness | frequencies | Observed positive-abundance taxa/categories. |
| Shannon entropy | Shannon, shannon_entropy, shannon_diversity | base, estimator, support | Entropy and effective diversity; low-count corrections. |
| Generalized entropy | Renyi, Tsallis, renyi_entropy, tsallis_entropy | order q, base | Diversity profiles and Hill-number relationships. |
| Simpson family | Simpson, GiniSimpson, InverseSimpson | frequencies | Dominance, Gini-Simpson diversity, and inverse Simpson diversity. |
| Hill numbers | Hill, hill_number, effective_diversity | order q | Effective number of species/categories. |
| Richness estimators | Chao1, ACE, chao1, ace | ACE threshold | Unseen-richness estimation from abundance frequency counts. |
| Coverage | SampleCoverage, sample_coverage | frequencies | Good-Turing style sample completeness. |
| Evenness | PielouEvenness, pielou_evenness | base | Shannon evenness relative to observed richness. |
| Fisher log-series | FisherAlpha, fisher_alpha | frequencies | Fisher's alpha diversity parameter. |
| Linguistic diversity | GreenbergDiversityIndex, LinguisticDiversityIndex, linguistic_diversity_index | frequencies | Gini-Simpson interpreted as probability of different mother tongues. |
Inputs
All methods accept the same data shapes: dictionaries, numeric vectors, observation vectors, community matrices, and Tables.jl-compatible tables. See Data Input Formats for the complete reference.
julia> richness(["oak", "ash", "oak", "elm"]) # observation vector
3
julia> richness([1, 2, 1, 3]; frequencies=false) # numeric obs. vector
3
julia> community = [1 1 2 0 5; 3 0 1 1 0];
julia> all(shannon_entropy(community) .≈ [1.6577427265048888, 1.3709505944546687])
trueEntropy And Effective Diversity
Shannon, Renyi, and Tsallis default to base=2, so entropy is reported in bits unless you choose another base.
\[H_b = -\sum_i p_i \log_b p_i\]
\[H_q = \frac{1}{1-q}\log_b\left(\sum_i p_i^q\right)\]
\[T_q = \frac{\sum_i p_i^q - 1}{(1-q)\log b}\]
The order q = 1 case for Renyi and Tsallis is evaluated as Shannon entropy. Effective diversity converts entropy-family quantities to Hill-number scale:
\[{}^qD = \left(\sum_i p_i^q\right)^{1/(1-q)}, \qquad {}^1D = b^H.\]
julia> entropy(Renyi(2), assemblage)
1.168122758808327
julia> effective_diversity(Renyi(2), assemblage)
2.247191011235955
julia> diversity(Hill(2), assemblage)
2.247191011235955Shannon Estimators And Low-Count Options
Shannon accepts estimator objects:
julia> entropy(Shannon(; estimator=Plugin()), assemblage)
1.3527241956246545
julia> entropy(Shannon(; estimator=MillerMadow()), assemblage)
1.4248589476691027
julia> entropy(Shannon(; estimator=AddGamma(1)), assemblage; support=5)
1.7792365361682794Use Plugin for the empirical estimate. Use MillerMadow for a simple observed-support bias correction. Use HausserStrimmer, Basharin, or AddGamma when a finite support is known. Use ChaoShen when support is unknown and unseen categories are plausible.
The support keyword can be an integer support size or a collection of known category labels:
julia> known_species = [:oak, :ash, :elm, :pine, :birch];
julia> entropy(Shannon(; estimator=AddGamma(0.5)), assemblage; support=known_species)
1.6295944962456386For uncertainty, use analytic helpers where available or resampling:
entropy_variance(Shannon(; estimator=Basharin()), assemblage; support=5)
entropy_confint(Shannon(; estimator=ChaoShen()), assemblage)
bootstrap(Shannon(; estimator=AddGamma(1)), assemblage; support=5)
jackknife(Shannon(; estimator=MillerMadow()), assemblage)Simpson, Linguistic Diversity, Richness, And Coverage
The Simpson family uses concentration
\[D = \sum_i p_i^2.\]
Simpson returns D, GiniSimpson returns 1 - D, and InverseSimpson returns 1 / D.
GreenbergDiversityIndex and LinguisticDiversityIndex are the same formula as Gini-Simpson but interpreted as the probability that two randomly selected people have different mother tongues.
Richness and coverage estimators use abundance-frequency counts:
julia> sparse = [5, 1, 1, 0, 0];
julia> richness(sparse)
3
julia> chao1(sparse)
4.0
julia> sample_coverage(sparse)
0.7142857142857143Availability Checklist
Legend: [x] is available directly; [~] is available indirectly or with a different convention; [ ] is not documented as available in the checked source. Last checked: 2026-05-13.
| Index or feature | DiversityAndDissimilarity.jl | Diversity.jl | vegan | iNEXT | scikit-bio | EcoPy | Microbiome.jl | SciPy | SpadeR | entropart | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Observed richness / number of taxa | [x] | [x] | [x] | [x] | [x] | [x] | [ ] | [ ] | [x] | [x] | Richness() / richness; vegan specnumber; scikit-bio sobs / observed_features; EcoPy spRich. |
| Chao / ACE richness estimators | [x] | [ ] | [x] | [x] | [x] | [ ] | [ ] | [ ] | [x] | [~] | Chao1() / chao1 and ACE() / ace; vegan estimateR / specpool; iNEXT ChaoRichness; scikit-bio chao1 and ace. |
| Rarefied richness / rarefaction curves | [ ] | [ ] | [x] | [x] | [~] | [x] | [ ] | [ ] | [~] | [ ] | Outside this package's core scope; vegan and iNEXT are stronger rarefaction tools. |
Shannon entropy, H | [x] | [~] | [x] | [~] | [x] | [x] | [x] | [ ] | [x] | [x] | Defaults to base=2 here; vegan defaults to natural logs. |
| Shannon effective diversity | [x] | [x] | [~] | [x] | [x] | [x] | [ ] | [ ] | [x] | [x] | effective_diversity(Shannon()); vegan derives it with exp(diversity(..., "shannon")). |
| Shannon entropy estimation | [x] | [ ] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] | [x] | [x] | Plugin, MillerMadow, HausserStrimmer, Basharin, AddGamma, and ChaoShen are available here. |
| Sample coverage | [x] | [ ] | [~] | [x] | [x] | [ ] | [ ] | [ ] | [x] | [x] | SampleCoverage() / sample_coverage; related coverage estimates appear in iNEXT, scikit-bio, SpadeR, and entropart. |
Simpson concentration, sum(p_i^2) | [x] | [~] | [~] | [~] | [~] | [x] | [ ] | [ ] | [x] | [x] | This package's Simpson() returns concentration; vegan index="simpson" returns 1-D. |
Gini-Simpson, 1 - sum(p_i^2) | [x] | [~] | [x] | [~] | [x] | [x] | [x] | [ ] | [x] | [~] | GiniSimpson(); vegan diversity(..., "simpson"). |
| Greenberg / linguistic diversity index | [x] | [~] | [~] | [~] | [~] | [~] | [~] | [ ] | [~] | [~] | Same formula as Gini-Simpson with linguistic-demography interpretation. |
| Inverse Simpson | [x] | [x] | [x] | [x] | [x] | [x] | [ ] | [ ] | [x] | [x] | InverseSimpson(); vegan index="invsimpson"; scikit-bio inv_simpson. |
Hill number, general order q | [x] | [x] | [~] | [x] | [x] | [~] | [ ] | [ ] | [x] | [x] | Hill(q) and hill_number; Diversity.jl is stronger for partitioned Hill/Jost diversity. |
| Renyi entropy / diversity profile | [x] | [~] | [x] | [ ] | [x] | [ ] | [ ] | [ ] | [~] | [x] | Renyi(q; base=2) / renyi_entropy; vegan renyi; scikit-bio renyi. |
| Tsallis entropy | [x] | [~] | [x] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] | [x] | Tsallis(q; base=2) / tsallis_entropy; vegan tsallis; scikit-bio tsallis. |
| Fisher alpha | [x] | [ ] | [x] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] | [ ] | FisherAlpha() / fisher_alpha; vegan fisher.alpha; scikit-bio fisher_alpha. |
| Evenness / equitability | [x] | [ ] | [~] | [ ] | [x] | [x] | [ ] | [ ] | [ ] | [ ] | PielouEvenness() / pielou_evenness; scikit-bio and EcoPy provide additional evenness metrics. |
| Dominance / Berger-Parker style metrics | [ ] | [ ] | [~] | [ ] | [x] | [x] | [ ] | [ ] | [ ] | [ ] | Simpson concentration is available here, but broader dominance families are not. |
| UniFrac / Faith phylogenetic diversity | [ ] | [x] | [~] | [ ] | [x] | [ ] | [ ] | [ ] | [ ] | [x] | Out of scope here; Diversity.jl and scikit-bio are stronger phylogenetic options. |
| Rao quadratic entropy | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [ ] | [~] | Specialist phylogenetic/functional diversity packages are better suited. |
| Alpha/beta/gamma diversity partitioning | [ ] | [x] | [x] | [~] | [~] | [x] | [ ] | [ ] | [~] | [x] | Not a core goal of this package. |
| Functional diversity | [ ] | [~] | [~] | [ ] | [~] | [ ] | [ ] | [ ] | [ ] | [x] | Specialist packages such as BAT, hillR, hilldiv, and entropart are stronger. |
Reference
DiversityAndDissimilarity.ShannonEstimator — Type
Abstract supertype for Shannon entropy estimators.
DiversityAndDissimilarity.Plugin — Type
Plugin estimator for Shannon entropy.
This is the maximum-likelihood estimator (MLE) obtained by substituting the empirical probabilities into Shannon's definition.
DiversityAndDissimilarity.MillerMadow — Type
Miller-Madow estimator for Shannon entropy.
For $S$ observed positive-abundance species and sample size $n$, the correction added to Shannon entropy is
\[\frac{S - 1}{2n\log b},\]
where $b$ is the logarithm base.
DiversityAndDissimilarity.HausserStrimmer — Type
Hausser-Strimmer shrinkage estimator for Shannon entropy.
This shrinks empirical probabilities towards the uniform distribution over the known or observed support, then applies the plugin entropy estimator.
DiversityAndDissimilarity.Basharin — Type
Basharin bias-reduced estimator for Shannon entropy.
For known support size $S$ and sample size $n$, the correction added to the plugin estimator is
\[\frac{S - 1}{n\log b},\]
where $b$ is the logarithm base.
DiversityAndDissimilarity.AddGamma — Type
AddGamma(gamma)Add-gamma estimator for Shannon entropy.
With support size $S$ and counts $n_i$, probabilities are estimated as
\[\hat p_i = \frac{n_i + \gamma}{n + \gamma S}.\]
DiversityAndDissimilarity.ChaoShen — Type
Chao-Shen estimator for Shannon entropy with possible unseen species.
This uses a Good-Turing coverage estimate and a Horvitz-Thompson adjustment. It is intended for samples where the true support may be larger than the observed support.
DiversityAndDissimilarity.Richness — Type
Species richness: the number of species/categories with positive abundance.
DiversityAndDissimilarity.Shannon — Type
Shannon(; base=2, estimator=Plugin())Shannon entropy/index. Use effective_diversity(Shannon(), x) for the corresponding Hill number, i.e. the effective number of species.
The default logarithm base is 2, so entropy is measured in bits unless another base is provided. Use estimator to choose among Plugin, MillerMadow, HausserStrimmer, Basharin, AddGamma, and ChaoShen.
\[H_b = -\sum_i p_i \log_b p_i\]
DiversityAndDissimilarity.Renyi — Type
Renyi(q; base=2)Renyi entropy of order q.
The default logarithm base is 2, so entropy is measured in bits unless another base is provided. At q = 1, Renyi entropy is evaluated as Shannon entropy.
\[H_q = \frac{1}{1-q}\log_b\left(\sum_i p_i^q\right)\]
DiversityAndDissimilarity.Tsallis — Type
Tsallis(q; base=2)Tsallis entropy of order q, scaled to the requested logarithm base.
The default logarithm base is 2. At q = 1, Tsallis entropy is evaluated as Shannon entropy with the same base.
\[T_q = \frac{\sum_i p_i^q - 1}{(1-q)\log b}\]
The $\log b$ denominator scales the result so that $T_1$ equals Shannon entropy in the same base. This differs from the standard Tsallis definition $(1 - \sum_i p_i^q)/(q-1)$, which does not include a logarithm base factor. Values will differ from packages that use the standard definition by a factor of $\log b$.
DiversityAndDissimilarity.Simpson — Type
Simpson concentration.
\[D = \sum_i p_i^2\]
DiversityAndDissimilarity.GiniSimpson — Type
Gini-Simpson diversity.
\[1 - D = 1 - \sum_i p_i^2\]
DiversityAndDissimilarity.GreenbergDiversityIndex — Type
Greenberg's linguistic diversity index.
This is the probability that two randomly selected individuals have different mother tongues. It is mathematically the same quantity as Gini-Simpson diversity:
\[1 - \sum_i p_i^2\]
The index uses only relative mother-tongue frequencies. It does not account for second-language use, language vitality, or linguistic distance between languages.
DiversityAndDissimilarity.LinguisticDiversityIndex — Type
Linguistic diversity index (LDI).
This is an alias-by-convention for GreenbergDiversityIndex, included for linguistic-demography workflows. It returns the probability that two randomly selected individuals have different mother tongues, equivalent to GiniSimpson.
DiversityAndDissimilarity.InverseSimpson — Type
Inverse Simpson diversity.
\[\frac{1}{D} = \frac{1}{\sum_i p_i^2}\]
DiversityAndDissimilarity.Hill — Type
Hill(q)Hill diversity of order q. Orders 0, 1, and 2 correspond to richness, Shannon effective diversity, and inverse Simpson diversity.
\[{}^qD = \left(\sum_i p_i^q\right)^{1/(1-q)}\]
DiversityAndDissimilarity.Chao1 — Type
Chao1 asymptotic richness estimator.
For observed richness $S_{obs}$, singleton count $f_1$, and doubleton count $f_2$, this package uses the bias-corrected abundance form
\[\hat S_{Chao1} = S_{obs} + \frac{f_1(f_1 - 1)}{2(f_2 + 1)}.\]
DiversityAndDissimilarity.ACE — Type
ACE(; threshold=10)Abundance-based Coverage Estimator (ACE) for richness.
Species with counts up to threshold are treated as rare. The default threshold=10 follows the usual ACE convention.
DiversityAndDissimilarity.SampleCoverage — Type
Good-Turing sample coverage estimate.
For sample size $n$ and singleton count $f_1$, sample coverage is
\[\hat C = 1 - \frac{f_1}{n}.\]
DiversityAndDissimilarity.PielouEvenness — Type
Pielou evenness, Shannon entropy divided by the maximum entropy for the observed richness.
\[J = \frac{H}{\log_b S}\]
DiversityAndDissimilarity.FisherAlpha — Type
Fisher's alpha diversity parameter.
Fisher's alpha solves
\[S = \alpha \log\left(1 + \frac{n}{\alpha}\right),\]
where $S$ is observed richness and $n$ is total abundance.
DiversityAndDissimilarity.entropy — Function
entropy(index, data; frequencies=true, support=nothing)Evaluate an entropy index for data.
entropy is defined for Shannon, Renyi, and Tsallis. For dictionaries, values are abundances. Numeric vectors are abundance vectors by default. Non-numeric vectors are raw observations. Pass frequencies=false to treat a numeric vector as raw observations instead.
For Shannon, support may be an integer support size or a collection of known categories. Leave support=nothing when only the observed support is known, or when using ChaoShen for possible unseen categories.
For community matrices, rows are samples and columns are taxa/categories. The result is one entropy value per row.
DiversityAndDissimilarity.entropy_variance — Function
entropy_variance(index, data; frequencies=true, support=nothing)Estimate the variance of a Shannon entropy estimator.
Analytic variance estimates are available for Plugin, MillerMadow, Basharin, and ChaoShen. For ChaoShen, this is an approximate Horvitz-Thompson detection variance. Use bootstrap or jackknife for estimators without an analytic variance estimate.
DiversityAndDissimilarity.entropy_confint — Function
entropy_confint(index, data; level=0.95, frequencies=true, support=nothing)Return a normal-approximation confidence interval for Shannon entropy using entropy_variance.
DiversityAndDissimilarity.diversity — Function
diversity(index, data; frequencies=true, support=nothing)Evaluate a diversity index for data.
For dictionaries, values are abundances. Numeric vectors are abundance vectors by default. Non-numeric vectors are raw observations. Pass frequencies=false to treat a numeric vector as raw observations instead.
For entropy-family indices, diversity returns the corresponding effective diversity. Use entropy when you want entropy units such as bits. For community matrices, rows are samples and columns are taxa/categories. The result is one diversity value per row.
DiversityAndDissimilarity.effective_diversity — Function
effective_diversity(index, data; frequencies=true)Return an index as an effective number of species when the transformation is standard. For Shannon entropy this is
\[{}^1D = b^H.\]
For community matrices, rows are samples and columns are taxa/categories. The result is one effective-diversity value per row.
DiversityAndDissimilarity.richness — Function
richness(data; frequencies=true)Return species richness for data.
DiversityAndDissimilarity.shannon — Function
shannon(data; base=2, estimator=Plugin(), frequencies=true, support=nothing)Alias for shannon_entropy.
DiversityAndDissimilarity.shannon_entropy — Function
shannon_entropy(data; base=2, estimator=Plugin(), frequencies=true, support=nothing)Return Shannon entropy for data.
The default logarithm base is 2, so entropy is measured in bits. Pass support when using finite-support estimators and the support is known.
DiversityAndDissimilarity.shannon_variance — Function
shannon_variance(data; base=2, estimator=Plugin(), frequencies=true, support=nothing)Return the estimated variance of a Shannon entropy estimator.
DiversityAndDissimilarity.shannon_confint — Function
shannon_confint(data; base=2, estimator=Plugin(), level=0.95, frequencies=true, support=nothing)Return a normal-approximation confidence interval for Shannon entropy.
DiversityAndDissimilarity.shannon_diversity — Function
shannon_diversity(data; base=2, estimator=Plugin(), frequencies=true, support=nothing)Return Shannon effective diversity for data.
\[{}^1D = b^H\]
The default logarithm base is 2, matching Shannon.
DiversityAndDissimilarity.bootstrap — Function
bootstrap(index, data; nboot=1000, level=0.95, quantity=:entropy, rng=nothing)Bootstrap a Shannon estimator from empirical abundance counts.
quantity=:entropy bootstraps entropy values. quantity=:diversity bootstraps effective Shannon diversity values. The returned named tuple contains the estimate, bootstrap variance, standard error, percentile interval, and replicates.
DiversityAndDissimilarity.jackknife — Function
jackknife(index, data; level=0.95, quantity=:entropy)Delete-one jackknife for Shannon entropy or Shannon effective diversity.
DiversityAndDissimilarity.renyi — Function
renyi(data, q; base=2, frequencies=true)Alias for renyi_entropy.
DiversityAndDissimilarity.renyi_entropy — Function
renyi_entropy(data, q; base=2, frequencies=true)Return Renyi entropy of order q for data.
The default logarithm base is 2, matching Renyi.
\[H_q = \frac{1}{1-q}\log_b\left(\sum_i p_i^q\right)\]
DiversityAndDissimilarity.renyi_diversity — Function
renyi_diversity(data, q; base=2, frequencies=true)Return the effective diversity corresponding to Renyi entropy of order q.
\[{}^qD = b^{H_q}\]
DiversityAndDissimilarity.tsallis — Function
tsallis(data, q; base=2, frequencies=true)Alias for tsallis_entropy.
DiversityAndDissimilarity.tsallis_entropy — Function
tsallis_entropy(data, q; base=2, frequencies=true)Return Tsallis entropy of order q for data.
The default logarithm base is 2, matching Tsallis.
\[T_q = \frac{\sum_i p_i^q - 1}{(1-q)\log b}\]
DiversityAndDissimilarity.tsallis_diversity — Function
tsallis_diversity(data, q; base=2, frequencies=true)Return the effective diversity corresponding to Tsallis entropy of order q.
\[{}^qD = \left(1 + (1-q)(\log b)T_q\right)^{1/(1-q)}\]
DiversityAndDissimilarity.hill_number — Function
hill_number(data, q; frequencies=true)Return the Hill number of order q for data.
DiversityAndDissimilarity.chao1 — Function
chao1(data; frequencies=true)Return the Chao1 richness estimate for data.
DiversityAndDissimilarity.ace — Function
ace(data; frequencies=true, threshold=10)Return the abundance-based coverage estimator (ACE) for richness.
DiversityAndDissimilarity.sample_coverage — Function
sample_coverage(data; frequencies=true)Return the Good-Turing sample coverage estimate for data.
DiversityAndDissimilarity.pielou_evenness — Function
pielou_evenness(data; frequencies=true)Return Pielou evenness, Shannon entropy divided by the maximum entropy for the observed richness.
DiversityAndDissimilarity.fisher_alpha — Function
fisher_alpha(data; frequencies=true)Return Fisher's alpha diversity parameter.
DiversityAndDissimilarity.simpson_index — Function
simpson_index(data; frequencies=true)Return Simpson concentration, $\sum_i p_i^2$, for data.
DiversityAndDissimilarity.gini_simpson_index — Function
gini_simpson_index(data; frequencies=true)Return Gini-Simpson diversity, $1 - \sum_i p_i^2$, for data.
DiversityAndDissimilarity.greenberg_diversity_index — Function
greenberg_diversity_index(data; frequencies=true)Return Greenberg's linguistic diversity index, the probability that two randomly selected individuals have different mother tongues.
This is equivalent to Gini-Simpson diversity, $1 - \sum_i p_i^2$.
DiversityAndDissimilarity.linguistic_diversity_index — Function
linguistic_diversity_index(data; frequencies=true)Return the linguistic diversity index (LDI), equivalent to greenberg_diversity_index.
DiversityAndDissimilarity.index_of_linguistic_diversity — Function
index_of_linguistic_diversity(current, baseline; frequencies=true)Return a Terralingua-style index of linguistic diversity (ILD) as the ratio of the current linguistic diversity index to a baseline linguistic diversity index.
A value of 1 indicates no change relative to the baseline; values below 1 indicate loss of linguistic diversity; values above 1 indicate an increase. This helper compares two assemblages and is therefore not itself a single-assemblage diversity index object.
DiversityAndDissimilarity.inverse_simpson_index — Function
inverse_simpson_index(data; frequencies=true)Return inverse Simpson diversity, $1 / \sum_i p_i^2$, for data.