Created
May 22, 2019 00:50
-
-
Save isaacovercast/61213d3ee6338ecb06f7569f22ffbd30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hill(p=.99, order=0): | |
""" Obviously doesn't work for H1 """ | |
## p is the frequency of the dominant species | |
p = p | |
q = 1-p | |
abunds = np.array([p*p, p*q, p*q, q*q]) | |
## Normalize abundances (not necessary here I guess) | |
abunds = abunds/np.sum(abunds) | |
## Random trait distances. | |
dij = np.array([0., 4.22207694, 4.22207694, 0.]) | |
V_bar = np.sum(dij * abunds) | |
print(np.sum(dij), V_bar) | |
return ((np.sum(dij*(abunds/V_bar)**order)**(1./(1-order)))/V_bar)**(1/2.) | |
#return ((np.sum(vals))/V_bar)**(1/2.) | |
[hill(order=x) for x in [0, 2, 3]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment