[R] Brillouin index

Ben Bolker bbolker at gmail.com
Fri Jan 13 23:54:42 CET 2012


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-ecology at r-project.org list ...



More information about the R-help mailing list