calc_simpson_index: Calculate the Simpson Diversity Index
Description
The Simpson diversity index is calculated to measure the probability that two randomly selected individuals
(e.g., molecular formulas) belong to the same category. It quantifies the dominance or evenness within a dataset.
The Simpson index is defined as:
$$D = \sum (p_i^2)$$
where:
\(p_i\) is the relative abundance of the \(i\)-th molecular formula.
The index ranges between 0 and 1:
A value near 0 indicates high diversity (even distribution of abundances).
A value of 1 indicates no diversity (one molecular formula dominates).
Usage
calc_simpson_index(mf, magnitude)
Value
A single numeric value representing the Simpson diversity index. Returns 0 if magnitude is all zeros.
Arguments
mf
Character vector. A list of unique molecular formulas.
magnitude
Numeric vector. A list of respective abundances (intensities) for each molecular formula.
Must be non-negative and have the same length as mf.