bray.proc <- function(pvect){
#
# Procedure to compute the normalized Bray heterogeneity measure
#
# Note: the input variable pvect is assumed to be a normalized
# probability vector that sums to 1 and is of length M.
# Missing values are not allowed, but components of pvector
# are allowed to be zero.
#
M <- length(pvect)
if (M == 1){
IBray <- 0
}
else{
prefactor <- M/(M-1)
refvect <- rep(1/M,M)
rawsum <- sum(pmin(pvect,refvect))
IBray <- prefactor * (1 - rawsum)
#
}
round(IBray,digits=6)
#
}