MacQueen, Don <macqueen1 <at> llnl.gov> writes: > > It's a pretty simple formula, according to the sources I found. > > Here's a function that looks right to me, but I have no independent > calculation with which to check it. > (no guarantees!) > > Hb <- function(ns) { > N <- sum(ns) > (lfactorial(N) - sum(lfactorial(ns)))/N > } > > > ns <- c(3,5,2,8) > > Hb(ns) > [1] 1.028802
Another source I found said that the index should be scaled by its maximum value, which assumes that all species are of equal diversity, which would be (lfactorial(N)-sum(lfactorial(mean(ns)))/N (the fact that mean(ns) is non-integer is not a problem; lfactorial() accepts non-integral values). Future questions like this *might* get more traction on the r-sig-ecol...@r-project.org list ... ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.