calc_simpson_index: Calculate the Simpson Diversity Index

calc_simpson_indexR Documentation

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)

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.

Value

A single numeric value representing the Simpson diversity index. Returns 0 if magnitude is all zeros.

Examples

calc_simpson_index(
  mf = c("C10H20O5", "C12H18O3", "C18H30O6"),
  magnitude = c(1982375, 2424, 312410)
)

ume documentation built on Dec. 13, 2025, 1:06 a.m.