piegy 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- piegy/__init__.py +4 -4
- piegy/__version__.py +3 -1
- piegy/analysis.py +58 -58
- piegy/data_tools.py +35 -35
- piegy/figures.py +80 -80
- piegy/{model.py → simulation.py} +109 -109
- piegy/test_var.py +25 -25
- piegy/tools/figure_tools.py +3 -3
- piegy/videos.py +21 -18
- {piegy-1.1.2.dist-info → piegy-1.1.4.dist-info}/METADATA +10 -7
- piegy-1.1.4.dist-info/RECORD +16 -0
- piegy-1.1.2.dist-info/RECORD +0 -16
- {piegy-1.1.2.dist-info → piegy-1.1.4.dist-info}/WHEEL +0 -0
- {piegy-1.1.2.dist-info → piegy-1.1.4.dist-info}/licenses/LICENSE.txt +0 -0
- {piegy-1.1.2.dist-info → piegy-1.1.4.dist-info}/top_level.txt +0 -0
piegy/figures.py
CHANGED
@@ -31,7 +31,7 @@ Popu-payoff correlation:
|
|
31
31
|
|
32
32
|
|
33
33
|
from .tools import figure_tools as figure_t
|
34
|
-
from . import
|
34
|
+
from . import simulation
|
35
35
|
|
36
36
|
import matplotlib.pyplot as plt
|
37
37
|
import numpy as np
|
@@ -43,18 +43,18 @@ CURVE_TYPE = '-'
|
|
43
43
|
|
44
44
|
|
45
45
|
|
46
|
-
def UV_heatmap(
|
46
|
+
def UV_heatmap(mod, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'Greens', start = 0.95, end = 1.0, annot = False, fmt = '.3g'):
|
47
47
|
'''
|
48
48
|
Makes two heatmaps for U, V average distribution over a time interval, respectively. Works best for 2D space.
|
49
49
|
1D works as well, but figures look bad.
|
50
50
|
|
51
51
|
Inputs:
|
52
|
-
|
52
|
+
mod: A simulation.model object.
|
53
53
|
ax_U, ax_V: matplotlib axes to plot on. New axes will be created if None is given.
|
54
54
|
U_color: Color for U's heatmap, uses matplotlib color maps.
|
55
55
|
V_color: Color for V's heatmap.
|
56
56
|
start: (0,1) float, where the interval should start from. Intended as a 'percentage'.
|
57
|
-
For example, start = 0.8 means the interval should start from the 80% point of
|
57
|
+
For example, start = 0.8 means the interval should start from the 80% point of mod.maxtime.
|
58
58
|
end: (0,1) float, where the interval ends.
|
59
59
|
annot: bool, whether to add annotations (show exact numbers for every patch).
|
60
60
|
fmt: Number format for annotations. How many digits you want to keep. Please set annot = True first and then use fmt.
|
@@ -63,12 +63,12 @@ def UV_heatmap(sim, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'Gr
|
|
63
63
|
ax_U, ax_V: matplotlib axes with heatmaps of U, V distribution plotted upon.
|
64
64
|
'''
|
65
65
|
|
66
|
-
start_index = int(start *
|
67
|
-
end_index = int(end *
|
66
|
+
start_index = int(start * mod.max_record)
|
67
|
+
end_index = int(end * mod.max_record)
|
68
68
|
|
69
69
|
# see ave_interval below
|
70
|
-
U_ave = figure_t.ave_interval(
|
71
|
-
V_ave = figure_t.ave_interval(
|
70
|
+
U_ave = figure_t.ave_interval(mod.U, start_index, end_index)
|
71
|
+
V_ave = figure_t.ave_interval(mod.V, start_index, end_index)
|
72
72
|
|
73
73
|
#### plot ####
|
74
74
|
|
@@ -84,29 +84,29 @@ def UV_heatmap(sim, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'Gr
|
|
84
84
|
|
85
85
|
|
86
86
|
|
87
|
-
def UV_bar(
|
87
|
+
def UV_bar(mod, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green', start = 0.95, end = 1.0):
|
88
88
|
'''
|
89
89
|
Makes two barplots for U, V average distribution over a time interval. Works best for 1D space.
|
90
90
|
2D works as well, but figures look bad.
|
91
91
|
|
92
92
|
Inputs:
|
93
|
-
|
93
|
+
mod: A simulation.model object.
|
94
94
|
ax_U, ax_V: matplotlib axes to plot on. New axes will be created if None is given.
|
95
95
|
U_color: Color of U's barplot. Uses Matplotlib colors.
|
96
96
|
See available colors at: https://matplotlib.org/stable/gallery/color/named_colors.html
|
97
97
|
V_color: Color of V's barplot. Uses Matplotlib colors.
|
98
|
-
start: (0,1) float. How much proportion of
|
98
|
+
start: (0,1) float. How much proportion of mod.maxtime you want the interval to start from.
|
99
99
|
end: (0,1) float. Where you want the interval to end.
|
100
100
|
|
101
101
|
Returns:
|
102
102
|
ax_U, ax_V: matplotlib axes with bar plots for U and V plotted upon.
|
103
103
|
'''
|
104
104
|
|
105
|
-
start_index = int(start *
|
106
|
-
end_index = int(end *
|
105
|
+
start_index = int(start * mod.max_record)
|
106
|
+
end_index = int(end * mod.max_record)
|
107
107
|
|
108
|
-
U_ave = figure_t.ave_interval_1D(
|
109
|
-
V_ave = figure_t.ave_interval_1D(
|
108
|
+
U_ave = figure_t.ave_interval_1D(mod.U, start_index, end_index)
|
109
|
+
V_ave = figure_t.ave_interval_1D(mod.V, start_index, end_index)
|
110
110
|
|
111
111
|
#### plot ####
|
112
112
|
|
@@ -123,7 +123,7 @@ def UV_bar(sim, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green',
|
|
123
123
|
|
124
124
|
|
125
125
|
|
126
|
-
def UV_dyna(
|
126
|
+
def UV_dyna(mod, ax = None, interval = 20, grid = True):
|
127
127
|
'''
|
128
128
|
Plots how total U, V change overtime.
|
129
129
|
The curves are not directly based on every single data point.
|
@@ -132,10 +132,10 @@ def UV_dyna(sim, ax = None, interval = 20, grid = True):
|
|
132
132
|
So if there are 2000 data points in total, then there will be 2000 / 20 = 100 points on the curves.
|
133
133
|
|
134
134
|
Inputs:
|
135
|
-
|
135
|
+
mod: A simulation.model object.
|
136
136
|
ax: matplotlib ax to plot on. New ax will be created if None is given.
|
137
137
|
interval: How many data points to take average over. Larger value makes curves smoother, but also loses local fluctuations.
|
138
|
-
NOTE: this interval doesn't overlap with
|
138
|
+
NOTE: this interval doesn't overlap with mod.compress_itv.
|
139
139
|
e.g. you already took average over every 20 data points, then using interval <= 20 here has no smoothing effect.
|
140
140
|
grid: Whether to add grid lines to plot.
|
141
141
|
|
@@ -148,19 +148,19 @@ def UV_dyna(sim, ax = None, interval = 20, grid = True):
|
|
148
148
|
V_curve = []
|
149
149
|
total_curve = []
|
150
150
|
|
151
|
-
interval = figure_t.scale_interval(interval,
|
152
|
-
interval_num = int(
|
151
|
+
interval = figure_t.scale_interval(interval, mod.compress_itv)
|
152
|
+
interval_num = int(mod.max_record / interval)
|
153
153
|
|
154
154
|
for i in range(interval_num):
|
155
|
-
U_ave = figure_t.ave_interval(
|
156
|
-
V_ave = figure_t.ave_interval(
|
155
|
+
U_ave = figure_t.ave_interval(mod.U, i * interval, (i + 1) * interval)
|
156
|
+
V_ave = figure_t.ave_interval(mod.V, i * interval, (i + 1) * interval)
|
157
157
|
|
158
158
|
U_curve.append(np.sum(U_ave))
|
159
159
|
V_curve.append(np.sum(V_ave))
|
160
160
|
total_curve.append(U_curve[-1] + V_curve[-1])
|
161
161
|
|
162
162
|
#### plot ####
|
163
|
-
xaxis = np.linspace(0,
|
163
|
+
xaxis = np.linspace(0, mod.maxtime, len(U_curve))
|
164
164
|
|
165
165
|
if ax == None:
|
166
166
|
_, ax = plt.subplots()
|
@@ -178,7 +178,7 @@ def UV_dyna(sim, ax = None, interval = 20, grid = True):
|
|
178
178
|
|
179
179
|
|
180
180
|
|
181
|
-
def UV_hist(
|
181
|
+
def UV_hist(mod, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green', start = 0.95, end = 1.0):
|
182
182
|
'''
|
183
183
|
Makes density histograms for U, V's average distribution over an interval.
|
184
184
|
Sometimes it may not be shown in density plots due to matplotlib features.
|
@@ -187,11 +187,11 @@ def UV_hist(sim, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green'
|
|
187
187
|
ax_U, ax_V: matplotlib axes with heatmaps of U, V population density plotted upon.
|
188
188
|
'''
|
189
189
|
|
190
|
-
start_index = int(start *
|
191
|
-
end_index = int(end *
|
190
|
+
start_index = int(start * mod.max_record)
|
191
|
+
end_index = int(end * mod.max_record)
|
192
192
|
|
193
|
-
U_ave = figure_t.ave_interval_1D(
|
194
|
-
V_ave = figure_t.ave_interval_1D(
|
193
|
+
U_ave = figure_t.ave_interval_1D(mod.U, start_index, end_index)
|
194
|
+
V_ave = figure_t.ave_interval_1D(mod.V, start_index, end_index)
|
195
195
|
|
196
196
|
#### plot ####
|
197
197
|
|
@@ -214,7 +214,7 @@ def UV_hist(sim, ax_U = None, ax_V = None, U_color = 'purple', V_color = 'green'
|
|
214
214
|
|
215
215
|
|
216
216
|
|
217
|
-
def UV_std(
|
217
|
+
def UV_std(mod, ax = None, interval = 20, grid = True):
|
218
218
|
'''
|
219
219
|
Plots how standard deviation of U, V change over time.
|
220
220
|
Takes average over many small interval to smooth out local fluctuations.
|
@@ -223,21 +223,21 @@ def UV_std(sim, ax = None, interval = 20, grid = True):
|
|
223
223
|
ax: matplotlib ax, contains U's and V's std curves.
|
224
224
|
'''
|
225
225
|
|
226
|
-
interval = figure_t.scale_interval(interval,
|
227
|
-
interval_num = int(
|
226
|
+
interval = figure_t.scale_interval(interval, mod.compress_itv)
|
227
|
+
interval_num = int(mod.max_record / interval)
|
228
228
|
|
229
229
|
U_std = []
|
230
230
|
V_std = []
|
231
231
|
|
232
232
|
for i in range(interval_num):
|
233
|
-
U_ave = figure_t.ave_interval(
|
234
|
-
V_ave = figure_t.ave_interval(
|
233
|
+
U_ave = figure_t.ave_interval(mod.U, i * interval, (i + 1) * interval)
|
234
|
+
V_ave = figure_t.ave_interval(mod.V, i * interval, (i + 1) * interval)
|
235
235
|
|
236
236
|
U_std.append(np.std(U_ave))
|
237
237
|
V_std.append(np.std(V_ave))
|
238
238
|
|
239
239
|
#### plot ####
|
240
|
-
xaxis = np.linspace(0,
|
240
|
+
xaxis = np.linspace(0, mod.maxtime, len(U_std))
|
241
241
|
|
242
242
|
if ax == None:
|
243
243
|
_, ax = plt.subplots()
|
@@ -253,33 +253,33 @@ def UV_std(sim, ax = None, interval = 20, grid = True):
|
|
253
253
|
|
254
254
|
|
255
255
|
|
256
|
-
def UV_expected_val(
|
256
|
+
def UV_expected_val(mod):
|
257
257
|
'''
|
258
258
|
Calculate expected U & V distribution based on matrices, assume no migration.
|
259
259
|
To differentiate from UV_expected in figures.py: this one return arrays (values).
|
260
260
|
'''
|
261
261
|
|
262
|
-
U_expected = np.zeros((
|
263
|
-
V_expected = np.zeros((
|
262
|
+
U_expected = np.zeros((mod.N, mod.M))
|
263
|
+
V_expected = np.zeros((mod.N, mod.M))
|
264
264
|
|
265
|
-
for i in range(
|
266
|
-
for j in range(
|
265
|
+
for i in range(mod.N):
|
266
|
+
for j in range(mod.M):
|
267
267
|
# say matrix = [a, b, c, d]
|
268
268
|
# U_proportion = (d - b) / (a - b - c + d)
|
269
|
-
U_prop = (
|
269
|
+
U_prop = (mod.X[i][j][3] - mod.X[i][j][1]) / (mod.X[i][j][0] - mod.X[i][j][1] - mod.X[i][j][2] + mod.X[i][j][3])
|
270
270
|
# equilibrium payoff, U_payoff = V_payoff
|
271
|
-
eq_payoff = U_prop *
|
271
|
+
eq_payoff = U_prop * mod.X[i][j][0] + (1 - U_prop) * mod.X[i][j][1]
|
272
272
|
|
273
273
|
# payoff / kappa * proportion
|
274
|
-
U_expected[i][j] = eq_payoff /
|
275
|
-
V_expected[i][j] = eq_payoff /
|
274
|
+
U_expected[i][j] = eq_payoff / mod.P[i][j][4] * U_prop
|
275
|
+
V_expected[i][j] = eq_payoff / mod.P[i][j][5] * (1 - U_prop)
|
276
276
|
|
277
277
|
return U_expected, V_expected
|
278
278
|
|
279
279
|
|
280
280
|
|
281
281
|
|
282
|
-
def UV_expected(
|
282
|
+
def UV_expected(mod, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'Greens', annot = False, fmt = '.3g'):
|
283
283
|
'''
|
284
284
|
Calculate expected population distribution based on matrices, assuming no migration.
|
285
285
|
For the formulas, see stochastic_mode.expected_UV
|
@@ -292,14 +292,14 @@ def UV_expected(sim, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'G
|
|
292
292
|
If 1D (N or M == 1), then ax_U and ax_V are barplots.
|
293
293
|
'''
|
294
294
|
|
295
|
-
U_expected, V_expected = UV_expected_val(
|
295
|
+
U_expected, V_expected = UV_expected_val(mod)
|
296
296
|
|
297
297
|
U_text = figure_t.gen_text(np.mean(U_expected), np.std(U_expected))
|
298
298
|
V_text = figure_t.gen_text(np.mean(V_expected), np.std(V_expected))
|
299
299
|
|
300
300
|
#### plot ####
|
301
301
|
|
302
|
-
if (
|
302
|
+
if (mod.N != 1) and (mod.M != 1):
|
303
303
|
# 2D
|
304
304
|
ax_U = figure_t.heatmap(U_expected, ax_U, U_color, annot, fmt, title = 'Expected U', text = U_text)
|
305
305
|
ax_V = figure_t.heatmap(V_expected, ax_V, V_color, annot, fmt, title = 'Expected V', text = V_text)
|
@@ -314,7 +314,7 @@ def UV_expected(sim, ax_U = None, ax_V = None, U_color = 'Purples', V_color = 'G
|
|
314
314
|
|
315
315
|
|
316
316
|
|
317
|
-
def pi_heatmap(
|
317
|
+
def pi_heatmap(mod, ax_U = None, ax_V = None, U_color = 'BuPu', V_color = 'YlGn', start = 0.95, end = 1.0, annot = False, fmt = '.3g'):
|
318
318
|
'''
|
319
319
|
Make heatmaps for payoff in a specified interval.
|
320
320
|
Works best for 2D. 1D works as well, but figures look bad.
|
@@ -326,11 +326,11 @@ def pi_heatmap(sim, ax_U = None, ax_V = None, U_color = 'BuPu', V_color = 'YlGn'
|
|
326
326
|
ax_U, ax_V: Seaborn heatmaps, for U's & V's payoff distribution, respectively.
|
327
327
|
'''
|
328
328
|
|
329
|
-
start_index = int(
|
330
|
-
end_index = int(
|
329
|
+
start_index = int(mod.max_record * start)
|
330
|
+
end_index = int(mod.max_record * end)
|
331
331
|
|
332
|
-
U_pi_ave = figure_t.ave_interval(
|
333
|
-
V_pi_ave = figure_t.ave_interval(
|
332
|
+
U_pi_ave = figure_t.ave_interval(mod.U_pi, start_index, end_index)
|
333
|
+
V_pi_ave = figure_t.ave_interval(mod.V_pi, start_index, end_index)
|
334
334
|
|
335
335
|
U_title = figure_t.gen_title('Payoff ' + r'$p_U$', start, end)
|
336
336
|
U_text = figure_t.gen_text(np.mean(U_pi_ave), np.std(U_pi_ave))
|
@@ -345,7 +345,7 @@ def pi_heatmap(sim, ax_U = None, ax_V = None, U_color = 'BuPu', V_color = 'YlGn'
|
|
345
345
|
|
346
346
|
|
347
347
|
|
348
|
-
def pi_bar(
|
348
|
+
def pi_bar(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgreen', start = 0.95, end = 1.0):
|
349
349
|
'''
|
350
350
|
Make barplot for payoff in a specified interval.
|
351
351
|
Works best for 1D. 2D works as well, but figures look bad.
|
@@ -354,11 +354,11 @@ def pi_bar(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowg
|
|
354
354
|
ax_U, ax_V: matplotlib axes with barplots of U and V payoff distribution plotted upon.
|
355
355
|
'''
|
356
356
|
|
357
|
-
start_index = int(
|
358
|
-
end_index = int(
|
357
|
+
start_index = int(mod.max_record * start)
|
358
|
+
end_index = int(mod.max_record * end)
|
359
359
|
|
360
|
-
U_pi_ave = figure_t.ave_interval_1D(
|
361
|
-
V_pi_ave = figure_t.ave_interval_1D(
|
360
|
+
U_pi_ave = figure_t.ave_interval_1D(mod.U_pi, start_index, end_index)
|
361
|
+
V_pi_ave = figure_t.ave_interval_1D(mod.V_pi, start_index, end_index)
|
362
362
|
|
363
363
|
U_title = figure_t.gen_title(r'$p_U$', start, end)
|
364
364
|
U_text = figure_t.gen_text(np.mean(U_pi_ave), np.std(U_pi_ave))
|
@@ -373,7 +373,7 @@ def pi_bar(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowg
|
|
373
373
|
|
374
374
|
|
375
375
|
|
376
|
-
def pi_dyna(
|
376
|
+
def pi_dyna(mod, ax = None, interval = 20, grid = True):
|
377
377
|
'''
|
378
378
|
Plot how payoffs change over time.
|
379
379
|
|
@@ -385,19 +385,19 @@ def pi_dyna(sim, ax = None, interval = 20, grid = True):
|
|
385
385
|
V_curve = []
|
386
386
|
total_curve = []
|
387
387
|
|
388
|
-
interval = figure_t.scale_interval(interval,
|
389
|
-
interval_num = int(
|
388
|
+
interval = figure_t.scale_interval(interval, mod.compress_itv)
|
389
|
+
interval_num = int(mod.max_record / interval)
|
390
390
|
|
391
391
|
for i in range(interval_num):
|
392
|
-
U_ave = figure_t.ave_interval(
|
393
|
-
V_ave = figure_t.ave_interval(
|
392
|
+
U_ave = figure_t.ave_interval(mod.U_pi, i * interval, (i + 1) * interval)
|
393
|
+
V_ave = figure_t.ave_interval(mod.V_pi, i * interval, (i + 1) * interval)
|
394
394
|
|
395
395
|
U_curve.append(np.sum(U_ave))
|
396
396
|
V_curve.append(np.sum(V_ave))
|
397
397
|
total_curve.append(U_curve[-1] + V_curve[-1])
|
398
398
|
|
399
399
|
#### plot ####
|
400
|
-
xaxis = np.linspace(0,
|
400
|
+
xaxis = np.linspace(0, mod.maxtime, len(U_curve))
|
401
401
|
|
402
402
|
if ax == None:
|
403
403
|
_, ax = plt.subplots()
|
@@ -415,7 +415,7 @@ def pi_dyna(sim, ax = None, interval = 20, grid = True):
|
|
415
415
|
|
416
416
|
|
417
417
|
|
418
|
-
def pi_hist(
|
418
|
+
def pi_hist(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgreen', start = 0.95, end = 1.0):
|
419
419
|
'''
|
420
420
|
Makes deensity histograms of U's and V's payoffs in a sepcified interval.
|
421
421
|
Sometimes it may not be shown in density plots due to matplotlib features.
|
@@ -424,11 +424,11 @@ def pi_hist(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellow
|
|
424
424
|
ax_U, ax_V: histogram of U's and V's payoff.
|
425
425
|
'''
|
426
426
|
|
427
|
-
start_index = int(start *
|
428
|
-
end_index = int(end *
|
427
|
+
start_index = int(start * mod.max_record)
|
428
|
+
end_index = int(end * mod.max_record)
|
429
429
|
|
430
|
-
U_pi_ave = figure_t.ave_interval_1D(
|
431
|
-
V_pi_ave = figure_t.ave_interval_1D(
|
430
|
+
U_pi_ave = figure_t.ave_interval_1D(mod.U_pi, start_index, end_index)
|
431
|
+
V_pi_ave = figure_t.ave_interval_1D(mod.V_pi, start_index, end_index)
|
432
432
|
|
433
433
|
#### plot ####
|
434
434
|
|
@@ -451,7 +451,7 @@ def pi_hist(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellow
|
|
451
451
|
|
452
452
|
|
453
453
|
|
454
|
-
def pi_std(
|
454
|
+
def pi_std(mod, ax = None, interval = 20, grid = True):
|
455
455
|
'''
|
456
456
|
Plots how standard deviation of payoff change over time.
|
457
457
|
|
@@ -460,21 +460,21 @@ def pi_std(sim, ax = None, interval = 20, grid = True):
|
|
460
460
|
'''
|
461
461
|
|
462
462
|
|
463
|
-
interval = figure_t.scale_interval(interval,
|
464
|
-
interval_num = int(
|
463
|
+
interval = figure_t.scale_interval(interval, mod.compress_itv)
|
464
|
+
interval_num = int(mod.max_record / interval)
|
465
465
|
|
466
466
|
U_pi_std = []
|
467
467
|
V_pi_std = []
|
468
468
|
|
469
469
|
for i in range(interval_num):
|
470
|
-
U_pi_ave = figure_t.ave_interval(
|
471
|
-
V_pi_ave = figure_t.ave_interval(
|
470
|
+
U_pi_ave = figure_t.ave_interval(mod.U_pi, i * interval, (i + 1) * interval)
|
471
|
+
V_pi_ave = figure_t.ave_interval(mod.V_pi, i * interval, (i + 1) * interval)
|
472
472
|
|
473
473
|
U_pi_std.append(np.std(U_pi_ave))
|
474
474
|
V_pi_std.append(np.std(V_pi_ave))
|
475
475
|
|
476
476
|
#### plot ####
|
477
|
-
xaxis = np.linspace(0,
|
477
|
+
xaxis = np.linspace(0, mod.maxtime, len(U_pi_std))
|
478
478
|
|
479
479
|
if ax == None:
|
480
480
|
_, ax = plt.subplots()
|
@@ -491,7 +491,7 @@ def pi_std(sim, ax = None, interval = 20, grid = True):
|
|
491
491
|
|
492
492
|
|
493
493
|
|
494
|
-
def UV_pi(
|
494
|
+
def UV_pi(mod, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgreen', alpha = 0.5, start = 0.95, end = 1.0):
|
495
495
|
'''
|
496
496
|
Make two scatter plots: x-axes are population and y-axes are payoff in a specified time interval.
|
497
497
|
Reveals relationship between population and payoff.
|
@@ -500,14 +500,14 @@ def UV_pi(sim, ax_U = None, ax_V = None, U_color = 'violet', V_color = 'yellowgr
|
|
500
500
|
ax_U, ax_V: matplotlib axes with U and V population-payoff scatter plots.
|
501
501
|
'''
|
502
502
|
|
503
|
-
start_index = int(start *
|
504
|
-
end_index = int(end *
|
503
|
+
start_index = int(start * mod.max_record)
|
504
|
+
end_index = int(end * mod.max_record)
|
505
505
|
|
506
|
-
U_ave = figure_t.ave_interval_1D(
|
507
|
-
V_ave = figure_t.ave_interval_1D(
|
506
|
+
U_ave = figure_t.ave_interval_1D(mod.U, start_index, end_index)
|
507
|
+
V_ave = figure_t.ave_interval_1D(mod.V, start_index, end_index)
|
508
508
|
|
509
|
-
U_pi_ave = figure_t.ave_interval(
|
510
|
-
V_pi_ave = figure_t.ave_interval(
|
509
|
+
U_pi_ave = figure_t.ave_interval(mod.U_pi, start_index, end_index)
|
510
|
+
V_pi_ave = figure_t.ave_interval(mod.V_pi, start_index, end_index)
|
511
511
|
|
512
512
|
|
513
513
|
ax_U = figure_t.scatter(U_ave, U_pi_ave, ax_U, U_color, alpha, xlabel = 'U', ylabel = 'Payoff ' + r'$p_U$', title = 'U - ' + r'$p_U$')
|