Bray-Curtis Index of Similarity
ANSI C Function

(Extracted from an application written in 1986 to perform cluster/factor/nodal analyses on benthic infaunal invertebrate core samples)

The following function was written in the ANSI-compatible C language (and compiled without errors in Microsoft C) to compute the Bray-Curtis Similarity Index for community structure as represented by two benthic invertebrate core samples in a "site x site" comparison, or the similarity in the spatial distribution of two distinct species in a "species x species" comparison.  It should be repeatedly called by the calling function within a "loop" that sequentially compares every possible pair of population arrays (e.g., sites), and it then returns the computed index between those pairs of populations, thereby "populating" a similarity matrix one cell at a time as the calling function progresses through the loop.

double bray_curtis (species1, species2, num_species)