%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import MESS
import numpy as np
import pandas as pd
import random
from IPython.display import display
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
The autoreload extension is already loaded. To reload it, use: %reload_ext autoreload
r = MESS.Region("watdo")
r.set_param("J", 250)
r.set_param("speciation_model", "none")
r.set_param("generations", 0.25)
r.run(sims=1)
Generating 1 simulation(s). [####################] 100% Finished 0 simulations | 0:00:00 |
loc1 = r.islands.values()[0]
mean_local_trait = loc1.region.get_trait_mean(loc1.local_community)
print(mean_local_trait)
local_traits = map(loc1.region.get_trait, loc1.local_community)
death_probs = map(lambda x: np.exp(-((x - mean_local_trait) ** 2)\
/loc1.region.metacommunity.paramsdict["ecological_strength"]),\
local_traits)
df = pd.DataFrame(local_traits)
df = pd.concat([df, pd.DataFrame(death_probs)], axis=1)
death_probs = np.array(death_probs)/np.sum(death_probs)
df = pd.concat([df, pd.DataFrame(death_probs)], axis=1)
df.columns = ["trait", "death_probs", "proba"]
display(df)
vic_idx = list(np.random.multinomial(1, death_probs)).index(1)
victim = loc1.local_community[vic_idx]
print(victim)
-1.989491511438099
trait | death_probs | proba | |
---|---|---|---|
0 | 3.283831 | 0.003843 | 0.000021 |
1 | -4.372301 | 0.321243 | 0.001715 |
2 | -7.139365 | 0.004970 | 0.000027 |
3 | -1.526951 | 0.958114 | 0.005114 |
4 | -1.526951 | 0.958114 | 0.005114 |
5 | -1.526951 | 0.958114 | 0.005114 |
6 | -1.526951 | 0.958114 | 0.005114 |
7 | -1.526951 | 0.958114 | 0.005114 |
8 | -1.526951 | 0.958114 | 0.005114 |
9 | -1.526951 | 0.958114 | 0.005114 |
10 | -1.526951 | 0.958114 | 0.005114 |
11 | -1.526951 | 0.958114 | 0.005114 |
12 | -1.526951 | 0.958114 | 0.005114 |
13 | -1.526951 | 0.958114 | 0.005114 |
14 | -1.526951 | 0.958114 | 0.005114 |
15 | -1.526951 | 0.958114 | 0.005114 |
16 | -1.526951 | 0.958114 | 0.005114 |
17 | -1.526951 | 0.958114 | 0.005114 |
18 | -7.139365 | 0.004970 | 0.000027 |
19 | -1.526951 | 0.958114 | 0.005114 |
20 | -1.526951 | 0.958114 | 0.005114 |
21 | -1.526951 | 0.958114 | 0.005114 |
22 | -1.526951 | 0.958114 | 0.005114 |
23 | -1.526951 | 0.958114 | 0.005114 |
24 | -1.526951 | 0.958114 | 0.005114 |
25 | -1.526951 | 0.958114 | 0.005114 |
26 | -1.526951 | 0.958114 | 0.005114 |
27 | -7.139365 | 0.004970 | 0.000027 |
28 | -1.526951 | 0.958114 | 0.005114 |
29 | -1.526951 | 0.958114 | 0.005114 |
30 | -1.526951 | 0.958114 | 0.005114 |
31 | 1.591805 | 0.076909 | 0.000411 |
32 | -7.139365 | 0.004970 | 0.000027 |
33 | -1.526951 | 0.958114 | 0.005114 |
34 | -1.526951 | 0.958114 | 0.005114 |
35 | -1.526951 | 0.958114 | 0.005114 |
36 | -1.526951 | 0.958114 | 0.005114 |
37 | -1.526951 | 0.958114 | 0.005114 |
38 | -1.526951 | 0.958114 | 0.005114 |
39 | 1.591805 | 0.076909 | 0.000411 |
40 | -1.526951 | 0.958114 | 0.005114 |
41 | -1.526951 | 0.958114 | 0.005114 |
42 | -7.139365 | 0.004970 | 0.000027 |
43 | -1.526951 | 0.958114 | 0.005114 |
44 | -1.526951 | 0.958114 | 0.005114 |
45 | -1.526951 | 0.958114 | 0.005114 |
46 | -1.526951 | 0.958114 | 0.005114 |
47 | -1.526951 | 0.958114 | 0.005114 |
48 | -1.526951 | 0.958114 | 0.005114 |
49 | -1.526951 | 0.958114 | 0.005114 |
50 | -1.526951 | 0.958114 | 0.005114 |
51 | -1.526951 | 0.958114 | 0.005114 |
52 | -1.526951 | 0.958114 | 0.005114 |
53 | -7.139365 | 0.004970 | 0.000027 |
54 | -1.526951 | 0.958114 | 0.005114 |
55 | -1.526951 | 0.958114 | 0.005114 |
56 | -1.526951 | 0.958114 | 0.005114 |
57 | -1.526951 | 0.958114 | 0.005114 |
58 | -1.526951 | 0.958114 | 0.005114 |
59 | -1.526951 | 0.958114 | 0.005114 |
60 | -1.526951 | 0.958114 | 0.005114 |
61 | -1.526951 | 0.958114 | 0.005114 |
62 | 3.283831 | 0.003843 | 0.000021 |
63 | -3.773968 | 0.528945 | 0.002823 |
64 | -1.526951 | 0.958114 | 0.005114 |
65 | -1.526951 | 0.958114 | 0.005114 |
66 | -7.139365 | 0.004970 | 0.000027 |
67 | -1.526951 | 0.958114 | 0.005114 |
68 | -1.526951 | 0.958114 | 0.005114 |
69 | -1.526951 | 0.958114 | 0.005114 |
70 | -1.526951 | 0.958114 | 0.005114 |
71 | -1.526951 | 0.958114 | 0.005114 |
72 | -1.526951 | 0.958114 | 0.005114 |
73 | -1.526951 | 0.958114 | 0.005114 |
74 | -1.526951 | 0.958114 | 0.005114 |
75 | -1.526951 | 0.958114 | 0.005114 |
76 | -1.526951 | 0.958114 | 0.005114 |
77 | -1.526951 | 0.958114 | 0.005114 |
78 | -1.526951 | 0.958114 | 0.005114 |
79 | -1.526951 | 0.958114 | 0.005114 |
80 | -1.526951 | 0.958114 | 0.005114 |
81 | -1.526951 | 0.958114 | 0.005114 |
82 | -1.526951 | 0.958114 | 0.005114 |
83 | -1.526951 | 0.958114 | 0.005114 |
84 | -1.526951 | 0.958114 | 0.005114 |
85 | -1.526951 | 0.958114 | 0.005114 |
86 | 1.591805 | 0.076909 | 0.000411 |
87 | -1.526951 | 0.958114 | 0.005114 |
88 | -1.526951 | 0.958114 | 0.005114 |
89 | -1.526951 | 0.958114 | 0.005114 |
90 | -1.526951 | 0.958114 | 0.005114 |
91 | -1.526951 | 0.958114 | 0.005114 |
92 | -1.526951 | 0.958114 | 0.005114 |
93 | -1.526951 | 0.958114 | 0.005114 |
94 | -1.526951 | 0.958114 | 0.005114 |
95 | -1.526951 | 0.958114 | 0.005114 |
96 | -7.139365 | 0.004970 | 0.000027 |
97 | -1.526951 | 0.958114 | 0.005114 |
98 | 3.283831 | 0.003843 | 0.000021 |
99 | -1.526951 | 0.958114 | 0.005114 |
100 | -1.526951 | 0.958114 | 0.005114 |
101 | -1.526951 | 0.958114 | 0.005114 |
102 | 1.591805 | 0.076909 | 0.000411 |
103 | -1.526951 | 0.958114 | 0.005114 |
104 | -1.526951 | 0.958114 | 0.005114 |
105 | -1.526951 | 0.958114 | 0.005114 |
106 | -1.526951 | 0.958114 | 0.005114 |
107 | -1.526951 | 0.958114 | 0.005114 |
108 | -1.526951 | 0.958114 | 0.005114 |
109 | -1.526951 | 0.958114 | 0.005114 |
110 | -1.526951 | 0.958114 | 0.005114 |
111 | -1.526951 | 0.958114 | 0.005114 |
112 | -1.526951 | 0.958114 | 0.005114 |
113 | -1.526951 | 0.958114 | 0.005114 |
114 | -1.526951 | 0.958114 | 0.005114 |
115 | -1.526951 | 0.958114 | 0.005114 |
116 | -1.526951 | 0.958114 | 0.005114 |
117 | -1.526951 | 0.958114 | 0.005114 |
118 | -1.526951 | 0.958114 | 0.005114 |
119 | 1.591805 | 0.076909 | 0.000411 |
120 | -1.526951 | 0.958114 | 0.005114 |
121 | -1.526951 | 0.958114 | 0.005114 |
122 | -1.526951 | 0.958114 | 0.005114 |
123 | -1.526951 | 0.958114 | 0.005114 |
124 | -1.526951 | 0.958114 | 0.005114 |
125 | -7.139365 | 0.004970 | 0.000027 |
126 | -1.526951 | 0.958114 | 0.005114 |
127 | -1.526951 | 0.958114 | 0.005114 |
128 | -1.526951 | 0.958114 | 0.005114 |
129 | -1.526951 | 0.958114 | 0.005114 |
130 | -1.526951 | 0.958114 | 0.005114 |
131 | -7.139365 | 0.004970 | 0.000027 |
132 | -1.526951 | 0.958114 | 0.005114 |
133 | -1.526951 | 0.958114 | 0.005114 |
134 | -1.526951 | 0.958114 | 0.005114 |
135 | -7.139365 | 0.004970 | 0.000027 |
136 | -1.526951 | 0.958114 | 0.005114 |
137 | 1.591805 | 0.076909 | 0.000411 |
138 | -1.526951 | 0.958114 | 0.005114 |
139 | -3.773968 | 0.528945 | 0.002823 |
140 | -7.139365 | 0.004970 | 0.000027 |
141 | -1.526951 | 0.958114 | 0.005114 |
142 | -7.139365 | 0.004970 | 0.000027 |
143 | 1.591805 | 0.076909 | 0.000411 |
144 | -7.139365 | 0.004970 | 0.000027 |
145 | -1.526951 | 0.958114 | 0.005114 |
146 | -1.526951 | 0.958114 | 0.005114 |
147 | -7.139365 | 0.004970 | 0.000027 |
148 | -1.526951 | 0.958114 | 0.005114 |
149 | -1.526951 | 0.958114 | 0.005114 |
150 | -1.526951 | 0.958114 | 0.005114 |
151 | -1.526951 | 0.958114 | 0.005114 |
152 | -1.526951 | 0.958114 | 0.005114 |
153 | -7.139365 | 0.004970 | 0.000027 |
154 | -1.526951 | 0.958114 | 0.005114 |
155 | -1.526951 | 0.958114 | 0.005114 |
156 | -1.526951 | 0.958114 | 0.005114 |
157 | -1.526951 | 0.958114 | 0.005114 |
158 | 1.591805 | 0.076909 | 0.000411 |
159 | -1.526951 | 0.958114 | 0.005114 |
160 | -1.526951 | 0.958114 | 0.005114 |
161 | -7.139365 | 0.004970 | 0.000027 |
162 | -1.526951 | 0.958114 | 0.005114 |
163 | -1.526951 | 0.958114 | 0.005114 |
164 | -1.526951 | 0.958114 | 0.005114 |
165 | -1.526951 | 0.958114 | 0.005114 |
166 | -1.526951 | 0.958114 | 0.005114 |
167 | -1.526951 | 0.958114 | 0.005114 |
168 | -1.526951 | 0.958114 | 0.005114 |
169 | -1.526951 | 0.958114 | 0.005114 |
170 | -1.526951 | 0.958114 | 0.005114 |
171 | -7.139365 | 0.004970 | 0.000027 |
172 | -1.526951 | 0.958114 | 0.005114 |
173 | -7.139365 | 0.004970 | 0.000027 |
174 | -7.139365 | 0.004970 | 0.000027 |
175 | -1.526951 | 0.958114 | 0.005114 |
176 | -1.526951 | 0.958114 | 0.005114 |
177 | -1.526951 | 0.958114 | 0.005114 |
178 | -1.526951 | 0.958114 | 0.005114 |
179 | -1.526951 | 0.958114 | 0.005114 |
180 | -1.526951 | 0.958114 | 0.005114 |
181 | 1.591805 | 0.076909 | 0.000411 |
182 | -7.139365 | 0.004970 | 0.000027 |
183 | -7.139365 | 0.004970 | 0.000027 |
184 | -1.526951 | 0.958114 | 0.005114 |
185 | -1.526951 | 0.958114 | 0.005114 |
186 | -1.526951 | 0.958114 | 0.005114 |
187 | -7.139365 | 0.004970 | 0.000027 |
188 | -1.526951 | 0.958114 | 0.005114 |
189 | -1.526951 | 0.958114 | 0.005114 |
190 | -1.526951 | 0.958114 | 0.005114 |
191 | -1.526951 | 0.958114 | 0.005114 |
192 | -1.526951 | 0.958114 | 0.005114 |
193 | -7.139365 | 0.004970 | 0.000027 |
194 | -1.526951 | 0.958114 | 0.005114 |
195 | -7.139365 | 0.004970 | 0.000027 |
196 | -1.526951 | 0.958114 | 0.005114 |
197 | -1.526951 | 0.958114 | 0.005114 |
198 | -1.526951 | 0.958114 | 0.005114 |
199 | -1.526951 | 0.958114 | 0.005114 |
200 | -1.526951 | 0.958114 | 0.005114 |
201 | -7.139365 | 0.004970 | 0.000027 |
202 | 3.283831 | 0.003843 | 0.000021 |
203 | -1.526951 | 0.958114 | 0.005114 |
204 | -7.139365 | 0.004970 | 0.000027 |
205 | -1.526951 | 0.958114 | 0.005114 |
206 | -1.526951 | 0.958114 | 0.005114 |
207 | -1.526951 | 0.958114 | 0.005114 |
208 | -1.526951 | 0.958114 | 0.005114 |
209 | -1.526951 | 0.958114 | 0.005114 |
210 | -1.526951 | 0.958114 | 0.005114 |
211 | 3.283831 | 0.003843 | 0.000021 |
212 | -1.526951 | 0.958114 | 0.005114 |
213 | 3.283831 | 0.003843 | 0.000021 |
214 | -1.526951 | 0.958114 | 0.005114 |
215 | -1.526951 | 0.958114 | 0.005114 |
216 | -1.526951 | 0.958114 | 0.005114 |
217 | -1.526951 | 0.958114 | 0.005114 |
218 | -7.139365 | 0.004970 | 0.000027 |
219 | 1.591805 | 0.076909 | 0.000411 |
220 | -1.526951 | 0.958114 | 0.005114 |
221 | -1.526951 | 0.958114 | 0.005114 |
222 | -1.526951 | 0.958114 | 0.005114 |
223 | -7.139365 | 0.004970 | 0.000027 |
224 | 1.591805 | 0.076909 | 0.000411 |
225 | -1.526951 | 0.958114 | 0.005114 |
226 | -1.526951 | 0.958114 | 0.005114 |
227 | -7.139365 | 0.004970 | 0.000027 |
228 | -1.526951 | 0.958114 | 0.005114 |
229 | -1.526951 | 0.958114 | 0.005114 |
230 | -7.139365 | 0.004970 | 0.000027 |
231 | -7.139365 | 0.004970 | 0.000027 |
232 | -7.139365 | 0.004970 | 0.000027 |
233 | -1.526951 | 0.958114 | 0.005114 |
234 | -1.526951 | 0.958114 | 0.005114 |
235 | -1.526951 | 0.958114 | 0.005114 |
236 | -1.526951 | 0.958114 | 0.005114 |
237 | -1.526951 | 0.958114 | 0.005114 |
238 | -1.526951 | 0.958114 | 0.005114 |
239 | -1.526951 | 0.958114 | 0.005114 |
240 | -7.139365 | 0.004970 | 0.000027 |
241 | -1.526951 | 0.958114 | 0.005114 |
242 | -7.139365 | 0.004970 | 0.000027 |
243 | -1.526951 | 0.958114 | 0.005114 |
244 | -7.139365 | 0.004970 | 0.000027 |
245 | -1.526951 | 0.958114 | 0.005114 |
246 | -1.526951 | 0.958114 | 0.005114 |
247 | -7.139365 | 0.004970 | 0.000027 |
248 | -1.526951 | 0.958114 | 0.005114 |
249 | -1.526951 | 0.958114 | 0.005114 |
t33
n = 20
loc1 = r.islands.values()[0]
print(loc1.region.metacommunity.paramsdict["ecological_strength"],\
loc1.region.metacommunity._hackersonly["filtering_optimum"])
local_traits = map(loc1.region.get_trait, loc1.local_community)
print(local_traits[:n])
fitness = map(lambda x: 1 - (np.exp(-((x - loc1.region.metacommunity._hackersonly["filtering_optimum"]) ** 2)\
/loc1.region.metacommunity.paramsdict["ecological_strength"])),\
local_traits)
## Scale all fitness values to proportions
df = pd.DataFrame(local_traits)
df = pd.concat([df, pd.DataFrame(fitness)], axis=1)
fitness = np.array(fitness)/np.sum(fitness)
df = pd.concat([df, pd.DataFrame(fitness)], axis=1)
df.columns = ["trait", "fitness", "proba"]
display(df)
## Get the victim conditioning on unequal death probability
vic_idx = list(np.random.multinomial(1, fitness)).index(1)
victim = loc1.local_community[vic_idx]
(5, 0.9925942189383941) [3.2838310962297093, -4.372301183457924, -7.13936514329368, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -1.52695126261639, -7.13936514329368, -1.52695126261639]
trait | fitness | proba | |
---|---|---|---|
0 | 3.283831 | 0.650046 | 0.003544 |
1 | -4.372301 | 0.996838 | 0.005435 |
2 | -7.139365 | 0.999998 | 0.005452 |
3 | -1.526951 | 0.719062 | 0.003920 |
4 | -1.526951 | 0.719062 | 0.003920 |
5 | -1.526951 | 0.719062 | 0.003920 |
6 | -1.526951 | 0.719062 | 0.003920 |
7 | -1.526951 | 0.719062 | 0.003920 |
8 | -1.526951 | 0.719062 | 0.003920 |
9 | -1.526951 | 0.719062 | 0.003920 |
10 | -1.526951 | 0.719062 | 0.003920 |
11 | -1.526951 | 0.719062 | 0.003920 |
12 | -1.526951 | 0.719062 | 0.003920 |
13 | -1.526951 | 0.719062 | 0.003920 |
14 | -1.526951 | 0.719062 | 0.003920 |
15 | -1.526951 | 0.719062 | 0.003920 |
16 | -1.526951 | 0.719062 | 0.003920 |
17 | -1.526951 | 0.719062 | 0.003920 |
18 | -7.139365 | 0.999998 | 0.005452 |
19 | -1.526951 | 0.719062 | 0.003920 |
20 | -1.526951 | 0.719062 | 0.003920 |
21 | -1.526951 | 0.719062 | 0.003920 |
22 | -1.526951 | 0.719062 | 0.003920 |
23 | -1.526951 | 0.719062 | 0.003920 |
24 | -1.526951 | 0.719062 | 0.003920 |
25 | -1.526951 | 0.719062 | 0.003920 |
26 | -1.526951 | 0.719062 | 0.003920 |
27 | -7.139365 | 0.999998 | 0.005452 |
28 | -1.526951 | 0.719062 | 0.003920 |
29 | -1.526951 | 0.719062 | 0.003920 |
30 | -1.526951 | 0.719062 | 0.003920 |
31 | 1.591805 | 0.069293 | 0.000378 |
32 | -7.139365 | 0.999998 | 0.005452 |
33 | -1.526951 | 0.719062 | 0.003920 |
34 | -1.526951 | 0.719062 | 0.003920 |
35 | -1.526951 | 0.719062 | 0.003920 |
36 | -1.526951 | 0.719062 | 0.003920 |
37 | -1.526951 | 0.719062 | 0.003920 |
38 | -1.526951 | 0.719062 | 0.003920 |
39 | 1.591805 | 0.069293 | 0.000378 |
40 | -1.526951 | 0.719062 | 0.003920 |
41 | -1.526951 | 0.719062 | 0.003920 |
42 | -7.139365 | 0.999998 | 0.005452 |
43 | -1.526951 | 0.719062 | 0.003920 |
44 | -1.526951 | 0.719062 | 0.003920 |
45 | -1.526951 | 0.719062 | 0.003920 |
46 | -1.526951 | 0.719062 | 0.003920 |
47 | -1.526951 | 0.719062 | 0.003920 |
48 | -1.526951 | 0.719062 | 0.003920 |
49 | -1.526951 | 0.719062 | 0.003920 |
50 | -1.526951 | 0.719062 | 0.003920 |
51 | -1.526951 | 0.719062 | 0.003920 |
52 | -1.526951 | 0.719062 | 0.003920 |
53 | -7.139365 | 0.999998 | 0.005452 |
54 | -1.526951 | 0.719062 | 0.003920 |
55 | -1.526951 | 0.719062 | 0.003920 |
56 | -1.526951 | 0.719062 | 0.003920 |
57 | -1.526951 | 0.719062 | 0.003920 |
58 | -1.526951 | 0.719062 | 0.003920 |
59 | -1.526951 | 0.719062 | 0.003920 |
60 | -1.526951 | 0.719062 | 0.003920 |
61 | -1.526951 | 0.719062 | 0.003920 |
62 | 3.283831 | 0.650046 | 0.003544 |
63 | -3.773968 | 0.989369 | 0.005394 |
64 | -1.526951 | 0.719062 | 0.003920 |
65 | -1.526951 | 0.719062 | 0.003920 |
66 | -7.139365 | 0.999998 | 0.005452 |
67 | -1.526951 | 0.719062 | 0.003920 |
68 | -1.526951 | 0.719062 | 0.003920 |
69 | -1.526951 | 0.719062 | 0.003920 |
70 | -1.526951 | 0.719062 | 0.003920 |
71 | -1.526951 | 0.719062 | 0.003920 |
72 | -1.526951 | 0.719062 | 0.003920 |
73 | -1.526951 | 0.719062 | 0.003920 |
74 | -1.526951 | 0.719062 | 0.003920 |
75 | -1.526951 | 0.719062 | 0.003920 |
76 | -1.526951 | 0.719062 | 0.003920 |
77 | -1.526951 | 0.719062 | 0.003920 |
78 | -1.526951 | 0.719062 | 0.003920 |
79 | -1.526951 | 0.719062 | 0.003920 |
80 | -1.526951 | 0.719062 | 0.003920 |
81 | -1.526951 | 0.719062 | 0.003920 |
82 | -1.526951 | 0.719062 | 0.003920 |
83 | -1.526951 | 0.719062 | 0.003920 |
84 | -1.526951 | 0.719062 | 0.003920 |
85 | -1.526951 | 0.719062 | 0.003920 |
86 | 1.591805 | 0.069293 | 0.000378 |
87 | -1.526951 | 0.719062 | 0.003920 |
88 | -1.526951 | 0.719062 | 0.003920 |
89 | -1.526951 | 0.719062 | 0.003920 |
90 | -1.526951 | 0.719062 | 0.003920 |
91 | -1.526951 | 0.719062 | 0.003920 |
92 | -1.526951 | 0.719062 | 0.003920 |
93 | -1.526951 | 0.719062 | 0.003920 |
94 | -1.526951 | 0.719062 | 0.003920 |
95 | -1.526951 | 0.719062 | 0.003920 |
96 | -7.139365 | 0.999998 | 0.005452 |
97 | -1.526951 | 0.719062 | 0.003920 |
98 | 3.283831 | 0.650046 | 0.003544 |
99 | -1.526951 | 0.719062 | 0.003920 |
100 | -1.526951 | 0.719062 | 0.003920 |
101 | -1.526951 | 0.719062 | 0.003920 |
102 | 1.591805 | 0.069293 | 0.000378 |
103 | -1.526951 | 0.719062 | 0.003920 |
104 | -1.526951 | 0.719062 | 0.003920 |
105 | -1.526951 | 0.719062 | 0.003920 |
106 | -1.526951 | 0.719062 | 0.003920 |
107 | -1.526951 | 0.719062 | 0.003920 |
108 | -1.526951 | 0.719062 | 0.003920 |
109 | -1.526951 | 0.719062 | 0.003920 |
110 | -1.526951 | 0.719062 | 0.003920 |
111 | -1.526951 | 0.719062 | 0.003920 |
112 | -1.526951 | 0.719062 | 0.003920 |
113 | -1.526951 | 0.719062 | 0.003920 |
114 | -1.526951 | 0.719062 | 0.003920 |
115 | -1.526951 | 0.719062 | 0.003920 |
116 | -1.526951 | 0.719062 | 0.003920 |
117 | -1.526951 | 0.719062 | 0.003920 |
118 | -1.526951 | 0.719062 | 0.003920 |
119 | 1.591805 | 0.069293 | 0.000378 |
120 | -1.526951 | 0.719062 | 0.003920 |
121 | -1.526951 | 0.719062 | 0.003920 |
122 | -1.526951 | 0.719062 | 0.003920 |
123 | -1.526951 | 0.719062 | 0.003920 |
124 | -1.526951 | 0.719062 | 0.003920 |
125 | -7.139365 | 0.999998 | 0.005452 |
126 | -1.526951 | 0.719062 | 0.003920 |
127 | -1.526951 | 0.719062 | 0.003920 |
128 | -1.526951 | 0.719062 | 0.003920 |
129 | -1.526951 | 0.719062 | 0.003920 |
130 | -1.526951 | 0.719062 | 0.003920 |
131 | -7.139365 | 0.999998 | 0.005452 |
132 | -1.526951 | 0.719062 | 0.003920 |
133 | -1.526951 | 0.719062 | 0.003920 |
134 | -1.526951 | 0.719062 | 0.003920 |
135 | -7.139365 | 0.999998 | 0.005452 |
136 | -1.526951 | 0.719062 | 0.003920 |
137 | 1.591805 | 0.069293 | 0.000378 |
138 | -1.526951 | 0.719062 | 0.003920 |
139 | -3.773968 | 0.989369 | 0.005394 |
140 | -7.139365 | 0.999998 | 0.005452 |
141 | -1.526951 | 0.719062 | 0.003920 |
142 | -7.139365 | 0.999998 | 0.005452 |
143 | 1.591805 | 0.069293 | 0.000378 |
144 | -7.139365 | 0.999998 | 0.005452 |
145 | -1.526951 | 0.719062 | 0.003920 |
146 | -1.526951 | 0.719062 | 0.003920 |
147 | -7.139365 | 0.999998 | 0.005452 |
148 | -1.526951 | 0.719062 | 0.003920 |
149 | -1.526951 | 0.719062 | 0.003920 |
150 | -1.526951 | 0.719062 | 0.003920 |
151 | -1.526951 | 0.719062 | 0.003920 |
152 | -1.526951 | 0.719062 | 0.003920 |
153 | -7.139365 | 0.999998 | 0.005452 |
154 | -1.526951 | 0.719062 | 0.003920 |
155 | -1.526951 | 0.719062 | 0.003920 |
156 | -1.526951 | 0.719062 | 0.003920 |
157 | -1.526951 | 0.719062 | 0.003920 |
158 | 1.591805 | 0.069293 | 0.000378 |
159 | -1.526951 | 0.719062 | 0.003920 |
160 | -1.526951 | 0.719062 | 0.003920 |
161 | -7.139365 | 0.999998 | 0.005452 |
162 | -1.526951 | 0.719062 | 0.003920 |
163 | -1.526951 | 0.719062 | 0.003920 |
164 | -1.526951 | 0.719062 | 0.003920 |
165 | -1.526951 | 0.719062 | 0.003920 |
166 | -1.526951 | 0.719062 | 0.003920 |
167 | -1.526951 | 0.719062 | 0.003920 |
168 | -1.526951 | 0.719062 | 0.003920 |
169 | -1.526951 | 0.719062 | 0.003920 |
170 | -1.526951 | 0.719062 | 0.003920 |
171 | -7.139365 | 0.999998 | 0.005452 |
172 | -1.526951 | 0.719062 | 0.003920 |
173 | -7.139365 | 0.999998 | 0.005452 |
174 | -7.139365 | 0.999998 | 0.005452 |
175 | -1.526951 | 0.719062 | 0.003920 |
176 | -1.526951 | 0.719062 | 0.003920 |
177 | -1.526951 | 0.719062 | 0.003920 |
178 | -1.526951 | 0.719062 | 0.003920 |
179 | -1.526951 | 0.719062 | 0.003920 |
180 | -1.526951 | 0.719062 | 0.003920 |
181 | 1.591805 | 0.069293 | 0.000378 |
182 | -7.139365 | 0.999998 | 0.005452 |
183 | -7.139365 | 0.999998 | 0.005452 |
184 | -1.526951 | 0.719062 | 0.003920 |
185 | -1.526951 | 0.719062 | 0.003920 |
186 | -1.526951 | 0.719062 | 0.003920 |
187 | -7.139365 | 0.999998 | 0.005452 |
188 | -1.526951 | 0.719062 | 0.003920 |
189 | -1.526951 | 0.719062 | 0.003920 |
190 | -1.526951 | 0.719062 | 0.003920 |
191 | -1.526951 | 0.719062 | 0.003920 |
192 | -1.526951 | 0.719062 | 0.003920 |
193 | -7.139365 | 0.999998 | 0.005452 |
194 | -1.526951 | 0.719062 | 0.003920 |
195 | -7.139365 | 0.999998 | 0.005452 |
196 | -1.526951 | 0.719062 | 0.003920 |
197 | -1.526951 | 0.719062 | 0.003920 |
198 | -1.526951 | 0.719062 | 0.003920 |
199 | -1.526951 | 0.719062 | 0.003920 |
200 | -1.526951 | 0.719062 | 0.003920 |
201 | -7.139365 | 0.999998 | 0.005452 |
202 | 3.283831 | 0.650046 | 0.003544 |
203 | -1.526951 | 0.719062 | 0.003920 |
204 | -7.139365 | 0.999998 | 0.005452 |
205 | -1.526951 | 0.719062 | 0.003920 |
206 | -1.526951 | 0.719062 | 0.003920 |
207 | -1.526951 | 0.719062 | 0.003920 |
208 | -1.526951 | 0.719062 | 0.003920 |
209 | -1.526951 | 0.719062 | 0.003920 |
210 | -1.526951 | 0.719062 | 0.003920 |
211 | 3.283831 | 0.650046 | 0.003544 |
212 | -1.526951 | 0.719062 | 0.003920 |
213 | 3.283831 | 0.650046 | 0.003544 |
214 | -1.526951 | 0.719062 | 0.003920 |
215 | -1.526951 | 0.719062 | 0.003920 |
216 | -1.526951 | 0.719062 | 0.003920 |
217 | -1.526951 | 0.719062 | 0.003920 |
218 | -7.139365 | 0.999998 | 0.005452 |
219 | 1.591805 | 0.069293 | 0.000378 |
220 | -1.526951 | 0.719062 | 0.003920 |
221 | -1.526951 | 0.719062 | 0.003920 |
222 | -1.526951 | 0.719062 | 0.003920 |
223 | -7.139365 | 0.999998 | 0.005452 |
224 | 1.591805 | 0.069293 | 0.000378 |
225 | -1.526951 | 0.719062 | 0.003920 |
226 | -1.526951 | 0.719062 | 0.003920 |
227 | -7.139365 | 0.999998 | 0.005452 |
228 | -1.526951 | 0.719062 | 0.003920 |
229 | -1.526951 | 0.719062 | 0.003920 |
230 | -7.139365 | 0.999998 | 0.005452 |
231 | -7.139365 | 0.999998 | 0.005452 |
232 | -7.139365 | 0.999998 | 0.005452 |
233 | -1.526951 | 0.719062 | 0.003920 |
234 | -1.526951 | 0.719062 | 0.003920 |
235 | -1.526951 | 0.719062 | 0.003920 |
236 | -1.526951 | 0.719062 | 0.003920 |
237 | -1.526951 | 0.719062 | 0.003920 |
238 | -1.526951 | 0.719062 | 0.003920 |
239 | -1.526951 | 0.719062 | 0.003920 |
240 | -7.139365 | 0.999998 | 0.005452 |
241 | -1.526951 | 0.719062 | 0.003920 |
242 | -7.139365 | 0.999998 | 0.005452 |
243 | -1.526951 | 0.719062 | 0.003920 |
244 | -7.139365 | 0.999998 | 0.005452 |
245 | -1.526951 | 0.719062 | 0.003920 |
246 | -1.526951 | 0.719062 | 0.003920 |
247 | -7.139365 | 0.999998 | 0.005452 |
248 | -1.526951 | 0.719062 | 0.003920 |
249 | -1.526951 | 0.719062 | 0.003920 |
r.set_param("community_assembly_model", "filtering")
r.set_param("generations", 0.25)
r.run(sims=1)
Generating 1 simulation(s). [####################] 100% Finished 0 simulations | 0:00:00 |
r = MESS.Region("watdo")
r.set_param("J", 250)
r.set_param("community_assembly_model", "neutral")
r.set_param("generations", 10)
r.run(sims=1)
Generating 1 simulation(s). [####################] 100% Finished 0 simulations | 0:00:00 |
r.set_param("community_assembly_model", "neutral")
%timeit r.simulate(nsteps=10)
1 loop, best of 3: 2.73 s per loop
r.set_param("community_assembly_model", "filtering")
%timeit r.simulate(nsteps=10)
1 loop, best of 3: 7.12 s per loop
r.set_param("community_assembly_model", "competition")
%timeit r.simulate(nsteps=10)
1 loop, best of 3: 29.9 s per loop
isl1 = r.islands.values()[0]
isl1.get_stats().T
for i in range(10):
isl1.step()
display(isl1.get_stats().T)
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 11.0 | 0.128 | 0.009455 | 0.002909 | 0.588235 | 0.470491 | 4.0 | 1.532446 | 1.238559 | 1.179619 | 1.158389 | 1.0 | 1.0 | 1.0 | 1.0 | 0.000088 | 0.000152 | 1.154701 | -0.666667 | 0.0 | 0.000088 | 0.010833 | 0.011301 | 0.864269 | -0.93968 | 0.006404 | 0.012763 | 0.0 | 7.012817 | 5.950356 | 5.350405 | 4.976124 | -1.346682 | 3.628484 | -1.02687 | -0.765367 | 0.22254 | 3.096023 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 2.380582 | -0.990928 | -0.771426 | 5.141217 | 1.250986 | -0.302622 | 0.8 | 0.774597 | -0.8 | 0.774597 | -0.2 | -0.774597 | 3.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 12.0 | 0.128 | 0.008667 | 0.002667 | 0.588235 | 0.470491 | 4.0 | 1.427437 | 1.178345 | 1.133737 | 1.118109 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -3.0 | 0.0 | 0.0 | 0.005439 | 0.005739 | 0.869128 | -0.936609 | 0.003158 | 0.006491 | 0.0 | 7.78585 | 6.849038 | 6.298498 | 5.904044 | -1.346682 | 3.628484 | -1.02687 | -0.765367 | 0.22254 | 3.096023 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 2.380582 | -0.990928 | -0.771426 | 5.141217 | 1.250986 | -0.302622 | 0.316228 | 0.0 | -0.948683 | 0.0 | 0.6 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 13.0 | 0.16 | 0.008 | 0.002462 | 0.588235 | 0.470491 | 4.0 | 1.475442 | 1.208008 | 1.15632 | 1.137939 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -3.0 | 0.0 | 0.0 | 0.002632 | 0.002102 | 0.918844 | -0.850429 | 0.001842 | 0.002018 | 0.0 | 7.443827 | 6.083974 | 5.52234 | 5.227341 | -1.346682 | 3.628484 | -1.02687 | -0.765367 | 0.22254 | 3.096023 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 2.380582 | -0.990928 | -0.771426 | 5.141217 | 1.250986 | -0.302622 | 0.4 | 0.0 | -1.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 14.0 | 0.16 | 0.008 | 0.002286 | 0.588235 | 0.470491 | 5.0 | 1.577247 | 1.260209 | 1.195661 | 1.172388 | 1.0 | 1.0 | 1.0 | 1.0 | 0.000125 | 0.00025 | 1.5 | 0.25 | 0.0 | 0.0 | 0.004912 | 0.005222 | 1.18965 | -0.126148 | 0.003509 | 0.002632 | 0.0 | 6.722715 | 5.333785 | 4.959513 | 4.78742 | -0.568785 | 3.599057 | -1.247896 | -0.083909 | 0.754532 | 1.989618 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 1.602685 | -0.961502 | -0.5504 | 4.459758 | 0.718994 | 0.803783 | -0.564288 | -0.544107 | -0.974679 | 0.353553 | 0.0 | 0.707107 | 4.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 15.0 | 0.164 | 0.009067 | 0.002133 | 0.588235 | 0.470491 | 7.0 | 1.584798 | 1.220901 | 1.164129 | 1.144692 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | -3.0 | 0.0 | 0.0 | 0.007343 | 0.005861 | 0.802411 | -0.436052 | 0.005263 | 0.007281 | 0.0 | 9.26804 | 7.516728 | 6.779976 | 6.412369 | 0.379826 | 3.398996 | -1.63791 | 1.258964 | 1.680166 | 2.21284 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 0.654074 | -0.76144 | -0.160386 | 3.116885 | -0.206639 | 0.580561 | -0.333562 | 0.0 | -0.704187 | 0.0 | 0.142857 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 7.0 | 0.0 | 0.0 | 0.0 | 0.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 16.0 | 0.164 | 0.01 | 0.002 | 0.588235 | 0.470491 | 8.0 | 1.790744 | 1.298804 | 1.220614 | 1.193959 | 1.0 | 1.0 | 1.0 | 1.0 | 0.000044 | 0.000116 | 2.267787 | 3.142857 | 0.0 | 0.0 | 0.00489 | 0.004941 | 0.965631 | -0.237424 | 0.003246 | 0.006579 | 0.0 | 8.095407 | 6.924013 | 6.59459 | 6.42646 | 0.312042 | 3.184523 | -1.679427 | 1.69096 | 1.217349 | 2.580866 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 0.721858 | -0.546968 | -0.118869 | 2.68489 | 0.256177 | 0.212536 | 0.25303 | 0.166957 | -0.289178 | -0.57735 | -0.142857 | -0.082479 | 7.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 17.0 | 0.148 | 0.009882 | 0.001882 | 0.588235 | 0.470491 | 9.0 | 1.786607 | 1.287744 | 1.212282 | 1.186696 | 2.0 | 2.0 | 2.0 | 2.0 | 0.000078 | 0.000146 | 1.336306 | -0.214286 | 0.0 | 0.0 | 0.008967 | 0.00644 | 1.115868 | 0.937138 | 0.007895 | 0.004737 | 0.0 | 7.931015 | 6.550788 | 6.193066 | 6.03231 | 0.71952 | 3.216006 | -1.666795 | 1.944897 | 1.680166 | 2.705252 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 0.31438 | -0.578451 | -0.131501 | 2.430953 | -0.206639 | 0.08815 | -0.169516 | -0.105279 | -0.186467 | -0.20702 | -0.016667 | 0.20702 | 7.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 18.0 | 0.156 | 0.009333 | 0.002667 | 0.588235 | 0.470491 | 7.0 | 1.617688 | 1.231914 | 1.171941 | 1.151511 | 1.0 | 1.0 | 1.0 | 1.0 | 0.00005 | 0.000123 | 2.041241 | 2.166667 | 0.0 | 0.0 | 0.006391 | 0.005492 | 1.810363 | 1.686737 | 0.004386 | 0.001491 | 0.0 | 8.539659 | 7.503744 | 7.166764 | 6.944117 | 0.024054 | 3.305516 | -1.486576 | 1.034793 | 0.754532 | 2.347435 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 1.009846 | -0.66796 | -0.31172 | 3.341057 | 0.718994 | 0.445966 | 0.272727 | 0.617914 | -0.180187 | 0.617914 | 0.306319 | -0.612372 | 6.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 19.0 | 0.18 | 0.010526 | 0.002526 | 0.588235 | 0.470491 | 9.0 | 1.712614 | 1.254345 | 1.18782 | 1.165364 | 2.0 | 2.0 | 2.0 | 2.0 | 0.000078 | 0.000146 | 1.336306 | -0.214286 | 0.0 | 0.0 | 0.003899 | 0.003267 | 0.197178 | -1.19327 | 0.003333 | 0.00614 | 0.0 | 8.656864 | 7.31869 | 6.936455 | 6.747551 | 0.71952 | 3.216006 | -1.666795 | 1.944897 | 1.680166 | 2.705252 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 0.31438 | -0.578451 | -0.131501 | 2.430953 | -0.206639 | 0.08815 | 0.0 | 0.421117 | -0.118661 | 0.207888 | -0.150629 | -0.517549 | 7.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2.0 |
J | m | speciation_prob | generation | _lambda | migrate_calculated | extrate_calculated | trait_rate_local | filtering_optimum | S | abund_h1 | abund_h2 | abund_h3 | abund_h4 | pi_h1 | pi_h2 | pi_h3 | pi_h4 | mean_pi | std_pi | skewness_pi | kurtosis_pi | median_pi | iqr_pi | mean_dxys | std_dxys | skewness_dxys | kurtosis_dxys | median_dxys | iqr_dxys | trees | trait_h1 | trait_h2 | trait_h3 | trait_h4 | mean_local_traits | std_local_traits | skewness_local_traits | kurtosis_local_traits | median_local_traits | iqr_local_traits | mean_regional_traits | std_regional_traits | skewness_regional_traits | kurtosis_regional_traits | median_regional_traits | iqr_regional_traits | reg_loc_mean_trait_dif | reg_loc_std_trait_dif | reg_loc_skewness_trait_dif | reg_loc_kurtosis_trait_dif | reg_loc_median_trait_dif | reg_loc_iqr_trait_dif | abundance_dxy_cor | abundance_pi_cor | abundance_trait_cor | dxy_pi_cor | dxy_trait_cor | pi_trait_cor | SGD_0 | SGD_1 | SGD_2 | SGD_3 | SGD_4 | SGD_5 | SGD_6 | SGD_7 | SGD_8 | SGD_9 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 250.0 | 0.01 | 0.0 | 20.0 | 0.172 | 0.01 | 0.0024 | 0.588235 | 0.470491 | 9.0 | 1.871276 | 1.333097 | 1.246152 | 1.216219 | 1.0 | 1.0 | 1.0 | 1.0 | 0.000039 | 0.00011 | 2.474874 | 4.125 | 0.0 | 0.0 | 0.00423 | 0.0043 | 1.533927 | 1.45223 | 0.003158 | 0.002456 | 0.0 | 6.584127 | 5.338629 | 5.016651 | 4.874048 | 0.71952 | 3.216006 | -1.666795 | 1.944897 | 1.680166 | 2.705252 | 1.0339 | 2.637555 | -1.798296 | 4.37585 | 1.473526 | 2.793401 | 0.31438 | -0.578451 | -0.131501 | 2.430953 | -0.206639 | 0.08815 | 0.231779 | 0.559503 | 0.025538 | 0.552345 | -0.445394 | -0.273861 | 8.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 1.0 |
r.paramsdict
r.set_param("speciation_rate", 5)
r = MESS.Region("watdo")
r.set_param("J", 1000)
r.set_param("community_assembly_model", "filtering")
r.set_param("speciation_prob", 0.001)
r.set_param("generations", 0.2)
r.set_param("ecological_strength", 0.01)
r.run(sims=1)
isl1 = r.islands.values()[0]
print(isl1.current_time * 2/isl1.paramsdict["J"])
Generating 1 simulation(s). [####################] 100% Finished 0 simulations | 0:00:00 | 25
%load_ext line_profiler
r.set_param("community_assembly_model", "filtering")
%lprun -T /tmp/rpt.txt -f isl1._filtering_death_step isl1._filtering_death_step()
!cat /tmp/rpt.txt
The line_profiler extension is already loaded. To reload it, use: %reload_ext line_profiler *** Profile printout saved to text file u'/tmp/rpt.txt'. Timer unit: 1e-06 s Total time: 0.010652 s File: /home/isaac/Continuosity/MESS/MESS/LocalCommunity.py Function: _filtering_death_step at line 482 Line # Hits Time Per Hit % Time Line Contents ============================================================== 482 def _filtering_death_step(self): 483 1 24.0 24.0 0.2 victim = random.choice(self.local_community) 484 1 2.0 2.0 0.0 if victim == None: 485 pass 486 else: 487 ## Get local traits for all individuals in the community (remove None first) 488 999 1272.0 1.3 11.9 loc_inds = [x for x in self.local_community if x != None] 489 # local_traits = map(self.region.get_trait, loc_inds) 490 # fo = self.region.metacommunity._hackersonly["filtering_optimum"] 491 # es = self.region.metacommunity.paramsdict["ecological_strength"] 492 # death_probs = map(lambda x: 1 - (np.exp(-((x - fo) ** 2)/es)), local_traits) 493 999 1232.0 1.2 11.6 death_probs = [self._filt_death_probs[x] for x in loc_inds] 494 ## Scale all fitness values to proportions 495 1 505.0 505.0 4.7 death_probs = np.array(death_probs)/np.sum(death_probs) 496 ## Get the victim conditioning on unequal death probability 497 1 7581.0 7581.0 71.2 vic_idx = list(np.random.multinomial(1, death_probs)).index(1) 498 1 2.0 2.0 0.0 victim = loc_inds[vic_idx] 499 500 1 34.0 34.0 0.3 self._finalize_death(victim)
Not with np.random.choice
loc_inds = [x for x in isl1.local_community if x != None]
local_traits = map(isl1.region.get_trait, loc_inds)
fo = isl1.region.metacommunity._hackersonly["filtering_optimum"]
es = isl1.region.metacommunity.paramsdict["ecological_strength"]
death_probs = [1 - (np.exp(-((x - fo) ** 2)/es)) for x in local_traits]
death_probs = np.array(death_probs)/np.sum(death_probs)
%timeit vic_idx = list(np.random.multinomial(1, death_probs)).index(1)
%timeit np.random.choice(loc_inds, size=1, p=death_probs)
100 loops, best of 3: 3.24 ms per loop 1000 loops, best of 3: 1.23 ms per loop
Not much
loc_inds = [x for x in isl1.local_community if x != None]
local_traits = map(isl1.region.get_trait, loc_inds)
fo = isl1.region.metacommunity._hackersonly["filtering_optimum"]
es = isl1.region.metacommunity.paramsdict["ecological_strength"]
%timeit death_probs = map(lambda x: 1 - (np.exp(-((x - fo) ** 2)/es)), local_traits)
%timeit [1 - (np.exp(-((x - fo) ** 2)/es)) for x in local_traits]
1000 loops, best of 3: 1.18 ms per loop 1000 loops, best of 3: 946 µs per loop
import random
loc_inds = [x for x in isl1.local_community if x != None]
# 1000000 loops, best of 3: 1.37 µs per loop
%timeit victim = random.choice(isl1.local_community)
# 100 loops, best of 3: 2.68 ms per loop
%timeit local_traits = map(isl1.region.get_trait, loc_inds)
dat = isl1.region.metacommunity.community
## DataFrame
df = pd.DataFrame(dat, index=dat["ids"])
# 10 loops, best of 3: 136 ms per loop
#%timeit map(lambda x: df.loc[x]["trait_values"], loc_inds)
# 10 loops, best of 3: 113 ms per loop
#%timeit [df.loc[x]["trait_values"] for x in loc_inds]
## Dictionary
trait_dict = {x["ids"]:x["trait_values"] for x in dat}
%timeit [isl1.region.get_trait(x) for x in loc_inds]
%timeit [trait_dict[x] for x in loc_inds]
%timeit map(lambda x:trait_dict[x], loc_inds)
The slowest run took 12.04 times longer than the fastest. This could mean that an intermediate result is being cached. 100000 loops, best of 3: 2.26 µs per loop 10000 loops, best of 3: 63.5 µs per loop 10000 loops, best of 3: 64.3 µs per loop 100000 loops, best of 3: 18.8 µs per loop 10000 loops, best of 3: 41.7 µs per loop
isl1.paramsdict
OrderedDict([('name', 'Loc1'), ('J', 250), ('m', 0.01), ('speciation_prob', 0.01)])
r = MESS.Region("watdo")
r.set_param("J", 500)
r.set_param("community_assembly_model", "filtering")
r.set_param("speciation_prob", 0.005)
r.set_param("m", 0.01)
r.set_param("generations", 0.5)
r.set_param("ecological_strength", 1)
r.run(sims=1)
isl1 = r.islands.values()[0]
print(isl1.current_time * 2/isl1.paramsdict["J"])
Generating 1 simulation(s). [####################] 100% Finished 0 simulations | 0:00:00 | 17
print(isl1.current_time * 2/isl1.paramsdict["J"])
ff_df = pd.DataFrame([isl1.founder_flags, isl1.local_community])
ff_df.T.groupby([0, 1]).size()
17
0 1 False t11 6 t17 144 t31 8 t31:Loc1-1712 8 t31:Loc1-3039 9 t31:Loc1-3245 6 t31:Loc1-3365 2 t31:Loc1-3384 4 t54 4 t62 5 t71 1 t97 64 t98 1 True t31 238 dtype: int64
es = isl1.region.metacommunity.paramsdict["ecological_strength"]
es = 1
def _filtering_death_step(self, es, comp=False):
victim = random.choice(self.local_community)
if victim == None:
pass
else:
## Get local traits for all individuals in the community (remove None first)
loc_inds = [x for x in self.local_community if x != None]
local_traits = map(self.region.get_trait, loc_inds)
if comp:
mean_local_trait = self.region.get_trait_mean(self.local_community)
print(mean_local_trait)
death_probs = map(lambda x: np.exp(-((x - mean_local_trait) ** 2)/(1./(es))),\
local_traits)
else:
print(isl1.region.metacommunity._hackersonly["filtering_optimum"])
death_probs = map(lambda x: 1 - (np.exp(-((x - self.region.metacommunity._hackersonly["filtering_optimum"]) ** 2)\
/es)),\
local_traits)
## Scale all fitness values to proportions
unscaled_dp = death_probs
death_probs = np.array(death_probs)/np.sum(death_probs)
df = pd.DataFrame([loc_inds, local_traits, unscaled_dp, list(death_probs)])
## Get the victim conditioning on unequal death probability
vic_idx = list(np.random.multinomial(1, death_probs)).index(1)
victim = loc_inds[vic_idx]
return df
for es in [0.001, 0.01, 0.1, 1, 10, 100, 1000]:
dp_df = _filtering_death_step(isl1, es, comp=False)
dp_df = pd.DataFrame(dp_df.T.groupby([0, 1, 2, 3]).size())
#dp_df.columns=["species", "trait value", "raw death prob", "scaled death prob"]
display(dp_df)#[0][[0, 1, 2, 3]])
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 1.0 | 0.002 | 6 |
t17 | 3.064223 | 1.0 | 0.002 | 144 |
t31 | -4.957767 | 1.0 | 0.002 | 246 |
t31:Loc1-1712 | -4.880348 | 1.0 | 0.002 | 8 |
t31:Loc1-3039 | -4.529044 | 1.0 | 0.002 | 9 |
t31:Loc1-3245 | -5.462708 | 1.0 | 0.002 | 6 |
t31:Loc1-3365 | -5.707546 | 1.0 | 0.002 | 2 |
t31:Loc1-3384 | -4.874942 | 1.0 | 0.002 | 4 |
t54 | 0.150870 | 1.0 | 0.002 | 4 |
t62 | -3.623747 | 1.0 | 0.002 | 5 |
t71 | 3.287411 | 1.0 | 0.002 | 1 |
t97 | 3.562160 | 1.0 | 0.002 | 64 |
t98 | -4.427946 | 1.0 | 0.002 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 1.000000 | 0.002 | 6 |
t17 | 3.064223 | 1.000000 | 0.002 | 144 |
t31 | -4.957767 | 1.000000 | 0.002 | 246 |
t31:Loc1-1712 | -4.880348 | 1.000000 | 0.002 | 8 |
t31:Loc1-3039 | -4.529044 | 1.000000 | 0.002 | 9 |
t31:Loc1-3245 | -5.462708 | 1.000000 | 0.002 | 6 |
t31:Loc1-3365 | -5.707546 | 1.000000 | 0.002 | 2 |
t31:Loc1-3384 | -4.874942 | 1.000000 | 0.002 | 4 |
t54 | 0.150870 | 1.000000 | 0.002 | 4 |
t62 | -3.623747 | 1.000000 | 0.002 | 5 |
t71 | 3.287411 | 1.000000 | 0.002 | 1 |
t97 | 3.562160 | 0.999762 | 0.002 | 64 |
t98 | -4.427946 | 1.000000 | 0.002 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 0.999681 | 0.002119 | 6 |
t17 | 3.064223 | 0.997950 | 0.002115 | 144 |
t31 | -4.957767 | 1.000000 | 0.002119 | 246 |
t31:Loc1-1712 | -4.880348 | 1.000000 | 0.002119 | 8 |
t31:Loc1-3039 | -4.529044 | 1.000000 | 0.002119 | 9 |
t31:Loc1-3245 | -5.462708 | 1.000000 | 0.002119 | 6 |
t31:Loc1-3365 | -5.707546 | 1.000000 | 0.002119 | 2 |
t31:Loc1-3384 | -4.874942 | 1.000000 | 0.002119 | 4 |
t54 | 0.150870 | 1.000000 | 0.002119 | 4 |
t62 | -3.623747 | 1.000000 | 0.002119 | 5 |
t71 | 3.287411 | 0.958252 | 0.002031 | 1 |
t97 | 3.562160 | 0.565763 | 0.001199 | 64 |
t98 | -4.427946 | 1.000000 | 0.002119 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 0.552986 | 0.001535 | 6 |
t17 | 3.064223 | 0.461509 | 0.001281 | 144 |
t31 | -4.957767 | 1.000000 | 0.002776 | 246 |
t31:Loc1-1712 | -4.880348 | 1.000000 | 0.002776 | 8 |
t31:Loc1-3039 | -4.529044 | 1.000000 | 0.002776 | 9 |
t31:Loc1-3245 | -5.462708 | 1.000000 | 0.002776 | 6 |
t31:Loc1-3365 | -5.707546 | 1.000000 | 0.002776 | 2 |
t31:Loc1-3384 | -4.874942 | 1.000000 | 0.002776 | 4 |
t54 | 0.150870 | 0.999999 | 0.002776 | 4 |
t62 | -3.623747 | 1.000000 | 0.002776 | 5 |
t71 | 3.287411 | 0.272113 | 0.000756 | 1 |
t97 | 3.562160 | 0.080032 | 0.000222 | 64 |
t98 | -4.427946 | 1.000000 | 0.002776 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 0.077360 | 0.000264 | 6 |
t17 | 3.064223 | 0.060022 | 0.000204 | 144 |
t31 | -4.957767 | 0.999573 | 0.003406 | 246 |
t31:Loc1-1712 | -4.880348 | 0.999511 | 0.003405 | 8 |
t31:Loc1-3039 | -4.529044 | 0.999108 | 0.003404 | 9 |
t31:Loc1-3245 | -5.462708 | 0.999829 | 0.003406 | 6 |
t31:Loc1-3365 | -5.707546 | 0.999892 | 0.003407 | 2 |
t31:Loc1-3384 | -4.874942 | 0.999507 | 0.003405 | 4 |
t54 | 0.150870 | 0.745659 | 0.002540 | 4 |
t62 | -3.623747 | 0.996254 | 0.003394 | 5 |
t71 | 3.287411 | 0.031262 | 0.000107 | 1 |
t97 | 3.562160 | 0.008307 | 0.000028 | 64 |
t98 | -4.427946 | 0.998945 | 0.003403 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 0.008019 | 0.000053 | 6 |
t17 | 3.064223 | 0.006171 | 0.000040 | 144 |
t31 | -4.957767 | 0.539729 | 0.003538 | 246 |
t31:Loc1-1712 | -4.880348 | 0.533436 | 0.003497 | 8 |
t31:Loc1-3039 | -4.529044 | 0.504530 | 0.003308 | 9 |
t31:Loc1-3245 | -5.462708 | 0.579978 | 0.003802 | 6 |
t31:Loc1-3365 | -5.707546 | 0.598944 | 0.003927 | 2 |
t31:Loc1-3384 | -4.874942 | 0.532996 | 0.003494 | 4 |
t54 | 0.150870 | 0.127950 | 0.000839 | 4 |
t62 | -3.623747 | 0.428057 | 0.002806 | 5 |
t71 | 3.287411 | 0.003171 | 0.000021 | 1 |
t97 | 3.562160 | 0.000834 | 0.000005 | 64 |
t98 | -4.427946 | 0.496114 | 0.003253 | 1 |
3.850979416620343
0 | ||||
---|---|---|---|---|
0 | 1 | 2 | 3 | |
t11 | 2.953669 | 0.000805 | 0.000038 | 6 |
t17 | 3.064223 | 0.000619 | 0.000029 | 144 |
t31 | -4.957767 | 0.074660 | 0.003551 | 246 |
t31:Loc1-1712 | -4.880348 | 0.073403 | 0.003492 | 8 |
t31:Loc1-3039 | -4.529044 | 0.067816 | 0.003226 | 9 |
t31:Loc1-3245 | -5.462708 | 0.083089 | 0.003952 | 6 |
t31:Loc1-3365 | -5.707546 | 0.087316 | 0.004153 | 2 |
t31:Loc1-3384 | -4.874942 | 0.073315 | 0.003487 | 4 |
t54 | 0.150870 | 0.013598 | 0.000647 | 4 |
t62 | -3.623747 | 0.054339 | 0.002585 | 5 |
t71 | 3.287411 | 0.000318 | 0.000015 | 1 |
t97 | 3.562160 | 0.000083 | 0.000004 | 64 |
t98 | -4.427946 | 0.066244 | 0.003151 | 1 |
dp_df[0]
0 1 2 3 t11 2.953669 0.000805 0.000038 6 t17 3.064223 0.000619 0.000029 144 t31 -4.957767 0.074660 0.003551 246 t31:Loc1-1712 -4.880348 0.073403 0.003492 8 t31:Loc1-3039 -4.529044 0.067816 0.003226 9 t31:Loc1-3245 -5.462708 0.083089 0.003952 6 t31:Loc1-3365 -5.707546 0.087316 0.004153 2 t31:Loc1-3384 -4.874942 0.073315 0.003487 4 t54 0.150870 0.013598 0.000647 4 t62 -3.623747 0.054339 0.002585 5 t71 3.287411 0.000318 0.000015 1 t97 3.562160 0.000083 0.000004 64 t98 -4.427946 0.066244 0.003151 1 Name: 0, dtype: int64
from collections import Counter
def neut_samp(isl):
self=isl
victim = random.choice(self.local_community)
return victim
def filt_samp(isl, es=0.01):
self = isl
loc_inds = [x for x in self.local_community if x != None]
local_traits = map(self.region.get_trait, loc_inds)
death_probs = map(lambda x: 1 - (np.exp(-((x - self.region.metacommunity._hackersonly["filtering_optimum"]) ** 2)\
/es)),\
local_traits)
## Scale all fitness values to proportions
#unscaled_dp = death_probs
death_probs = np.array(death_probs)/np.sum(death_probs)
#df = pd.DataFrame([loc_inds, local_traits, unscaled_dp, list(death_probs)])
## Get the victim conditioning on unequal death probability
vic_idx = list(np.random.multinomial(1, death_probs)).index(1)
victim = loc_inds[vic_idx]
return victim
print(Counter([neut_samp(isl1) for _ in range(500)]))
print(Counter([filt_samp(isl1, es=0.01) for _ in range(500)]))
Counter({'t43': 397, 't16': 28, 't11': 18, 't94': 13, 't7': 12, 't17': 9, 't38': 6, 't29': 5, 't44': 4, 't10': 3, 't47': 2, 't80': 2, 't84': 1}) Counter({'t43': 398, 't16': 27, 't11': 27, 't7': 13, 't38': 9, 't94': 9, 't29': 7, 't44': 3, 't84': 3, 't17': 2, 't10': 1, 't80': 1})