The Margalev Index (D) is a simple metric useful for the purpose of measuring diversity.
The index is only applicable for categorical data where all observations can be classified into a finite number of categories (species, types etc)
More precisely, if we have n observations values and a total of S categories, then the D index is defined as
Open Source implementations of the Margalev index are available in
- the Python library Concentration Library
- the EcoIndR R package