-
Notifications
You must be signed in to change notification settings - Fork 9
/
Hill.jl
36 lines (27 loc) · 1004 Bytes
/
Hill.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# SPDX-License-Identifier: BSD-2-Clause
using Diversity
using DataFrames
using EcoBase
"""
hillnumber(proportions, qs)
Calculate the Hill number (or naive diversity) of order q of
population(s) with given relative proportions
# Arguments:
- `proportions`: relative proportions of different individuals / species
in population (vector, or matrix where columns are
individual populations)
- `qs`: single number or vector of orders of diversity measurement
# Returns:
- Diversity of order qs (single number or vector of diversities)
"""
function hillnumber(proportions, qs)
hill = subdiv(NormalisedAlpha(Metacommunity(proportions)), qs)
hill[!, :measure] .= "HillNumber"
select!(hill, Not(:div_type))
return hill
end
function hillnumber(asm::EcoBase.AbstractAssemblage, qs)
hassimilarity(asm) &&
error("function cannot run with $(typeof(gettypes(asm))) types as contains similarity")
return hillnumber(occurrences(asm), qs)
end