def combinations(n, k): """Returns the number of ways of choosing k items from n. """ return exp(lgam(n+1) - lgam(k+1) - lgam(n-k+1))
def brillouin_d(counts): """Brilloun index of alpha diversity: Pielou 1975, by way of SDR-IV.""" nz = counts[counts.nonzero()] n = nz.sum() return (lgam(n+1) - array(map(lgam, nz+1)).sum())/n
def brillouin_d(counts): """Brilloun index of alpha diversity: Pielou 1975, by way of SDR-IV.""" nz = counts[counts.nonzero()] n = nz.sum() return (lgam(n + 1) - array(map(lgam, nz + 1)).sum()) / n