new version
This commit is contained in:
parent
57368db7a9
commit
0bc7632c58
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
||||
.DS_Store
|
||||
graph
|
||||
wos-data*
|
||||
!wos-data-complete
|
||||
user*
|
||||
*.svg
|
||||
__pycache__
|
||||
.vscode/
|
||||
.vscode
|
||||
BIN
.vscode/.ropeproject/objectdb
vendored
BIN
.vscode/.ropeproject/objectdb
vendored
Binary file not shown.
@ -3,7 +3,8 @@ from matplotlib import pyplot as plt
|
||||
from island.match import Match
|
||||
from island.matches import Matches
|
||||
|
||||
matches = Matches('wos-data-new')
|
||||
mode = 'SURVIVE'
|
||||
matches = Matches.from_profile_expr(lambda r: mode in r)
|
||||
|
||||
labels = ['Stay Connected', 'Break Tie']
|
||||
percents = [0.0, 0.0]
|
||||
@ -16,7 +17,7 @@ for m in matches.data:
|
||||
|
||||
for row in m.query('action', 'done').where(lambda x: x['act_a'] == op or x['act_b'] == op).raw_data:
|
||||
if row['rno'] == game_end_at:
|
||||
print(row)
|
||||
# print(row)
|
||||
continue
|
||||
if row['act_a'] == op:
|
||||
a = row['a']
|
||||
@ -46,4 +47,4 @@ plt.pie(percents, labels=labels, autopct="%1.2f%%", pctdistance=1.1, labeldistan
|
||||
plt.legend()
|
||||
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
|
||||
# plt.show()
|
||||
plt.savefig("graph/break_tie_%s.eps"%op)
|
||||
plt.savefig("graph/break_tie_%s_%s.eps"%(op, mode))
|
||||
|
||||
@ -1,6 +1,15 @@
|
||||
from scipy.stats import chi2_contingency as chi2
|
||||
import numpy as np
|
||||
|
||||
obs = np.array([[219,113],[661,25]])
|
||||
obs = np.array([[2887.0, 459.0], [61.0, 383.0]])
|
||||
chi,p,dof,expected = chi2(obs)
|
||||
print("%f, %f, %f" % (chi, p, dof))
|
||||
print("%f, %e, %f" % (chi, p, dof))
|
||||
|
||||
'''
|
||||
survive:
|
||||
chi = 1189.53, p = 1.149752e-260
|
||||
|
||||
survive:
|
||||
chi = 611.59, p = 5.031232e-135
|
||||
|
||||
'''
|
||||
|
||||
@ -4,7 +4,7 @@ from island.match import Match
|
||||
from island.matches import Matches
|
||||
import numpy as np
|
||||
|
||||
matches = Matches('wos-data-compete')
|
||||
matches = Matches.from_profile_expr(lambda r: True)
|
||||
max_round = 15
|
||||
|
||||
total_players = 0
|
||||
|
||||
@ -8,18 +8,19 @@ result = 0
|
||||
count = 0
|
||||
|
||||
# ms = Matches.from_profile('CCCN')
|
||||
ms = Matches.from_profile_expr(lambda r: 'LAB' in r and 'SURVIVE' in r and 'COMM' in r)
|
||||
ms = Matches.from_profile_expr(lambda r: True)
|
||||
for m in ms.data:
|
||||
result += len(m.query('player', 'join').where(lambda x: 'bot' not in x or x['bot'] == False).select('pid').raw_data)
|
||||
count += 1
|
||||
|
||||
print(result)
|
||||
print("avg:", result / count)
|
||||
print("participants: %d, matches: %d, avg: %f" % (result, count, result / count))
|
||||
# 146 users
|
||||
# casual: 324
|
||||
# new(254-354, 全国复杂网络大会): 205
|
||||
# new-2(375-421, 无交流): 320
|
||||
# new-3(426-440, 有交流): 203
|
||||
# new-4(443-472, 经典模式,无交流): 230
|
||||
# new-5(474-,经典模式,有交流): 159
|
||||
# total: 1117
|
||||
# new-5(474-,经典模式,有交流): 286
|
||||
# total: 1244, 81, 15.35
|
||||
# lab: 1039, 69, 15.05
|
||||
|
||||
@ -4,11 +4,11 @@ from island.match import Match
|
||||
|
||||
result = {}
|
||||
|
||||
for file in Path('wos-data-compete').iterdir():
|
||||
p = Path(file)
|
||||
for f in Path('wos-data-compete').iterdir():
|
||||
p = Path(f)
|
||||
if p.suffix == '.json':
|
||||
name = p.stem
|
||||
m = Match.read_from_json(str(file))
|
||||
m = Match.read_from_json(str(f))
|
||||
info = m.query('game', 'created').select('info').first()['info']
|
||||
conf = json.loads(info['config'])
|
||||
game_end_at = int(info['game_end_at'])
|
||||
|
||||
@ -4,7 +4,8 @@ from island.match import Match
|
||||
from island.matches import Matches
|
||||
import numpy as np
|
||||
|
||||
matches = Matches('wos-data-new-3')
|
||||
|
||||
matches = Matches.from_profile_expr(lambda r: 'CLASSIC' in r)
|
||||
max_round = 15
|
||||
|
||||
coopr = []
|
||||
@ -14,7 +15,7 @@ x = np.arange(1, max_round+1)
|
||||
bx = []
|
||||
|
||||
survivals = {}
|
||||
with open('winner.json','r') as f:
|
||||
with open('survivals.json','r') as f:
|
||||
survivals = json.load(f)
|
||||
|
||||
for i in range(max_round):
|
||||
@ -46,4 +47,4 @@ plt.figure()
|
||||
# plt.boxplot(bx, showmeans=True, meanline=True)
|
||||
plt.plot(x, coopr)
|
||||
plt.show()
|
||||
# plt.savefig('graph/co_per_round.png')
|
||||
# plt.savefig('graph/co_per_round.png')
|
||||
|
||||
@ -3,11 +3,12 @@ from matplotlib import pyplot as plt
|
||||
from island.match import Match
|
||||
from island.matches import Matches
|
||||
|
||||
matches = Matches('wos-data-new')
|
||||
mode = 'SURVIVE'
|
||||
matches = Matches.from_profile_expr(lambda r: mode in r)
|
||||
|
||||
percents = [0.0, 0.0]
|
||||
|
||||
op = 'C'
|
||||
op = 'D'
|
||||
|
||||
def get_reason(m, i, target):
|
||||
r = m.query('action', 'request').where(lambda x: x['rno'] == i+1 and x['from'] == target).raw_data
|
||||
@ -52,11 +53,11 @@ percents[0] /= _all
|
||||
percents[1] /= _all
|
||||
|
||||
|
||||
labels = ['Insufficient Temporal Resource', 'Sufficient Temporal Resource']
|
||||
labels = ['Insufficient Time Resource', 'Sufficient Time Resource']
|
||||
|
||||
plt.figure()
|
||||
plt.pie(percents, labels=labels, autopct="%1.2f%%", pctdistance=1.1, labeldistance=2,startangle=90, colors=['#00b894', '#fdcb6e'])
|
||||
plt.legend()
|
||||
plt.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
|
||||
# plt.show()
|
||||
plt.savefig("graph/fail_reason_%s.eps"%op)
|
||||
plt.savefig("graph/fail_reason_%s_%s.eps"%(op, mode))
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
from scipy.stats import chi2_contingency as chi2
|
||||
import numpy as np
|
||||
|
||||
obs = np.array([[159,90],[53,24]])
|
||||
obs = np.array([[203.0, 49.0], [279.0, 78.0]])
|
||||
chi,p,dof,expected = chi2(obs)
|
||||
print("%f, %f, %f" % (chi, p, dof))
|
||||
print("%f, %e, %f" % (chi, p, dof))
|
||||
|
||||
'''
|
||||
classic
|
||||
chi = 0.381964, p = 0.536554
|
||||
|
||||
survive
|
||||
chi = 23.490576, p = 1.255272e-06
|
||||
'''
|
||||
|
||||
@ -5,15 +5,15 @@ from island.matches import Matches
|
||||
import numpy as np
|
||||
from scipy.stats import pearsonr
|
||||
|
||||
mode = 'CLASSIC'
|
||||
matches = Matches.from_profile_expr(lambda r: mode in r)
|
||||
|
||||
matches = Matches('wos-data-new-2')
|
||||
|
||||
k = np.arange(2, 11)
|
||||
succ = np.zeros(9)
|
||||
total = np.zeros(9)
|
||||
k = np.arange(5, 11)
|
||||
succ = np.zeros(10)
|
||||
total = np.zeros(10)
|
||||
|
||||
survivals = {}
|
||||
with open('survivals-2.json', 'r') as f:
|
||||
with open('survivals.json', 'r') as f:
|
||||
survivals = json.load(f)
|
||||
|
||||
neighbors = {}
|
||||
@ -73,10 +73,23 @@ for m_i in range(len(matches.data)):
|
||||
else:
|
||||
if r['a'] not in previous_round_partner:
|
||||
new_partner_succ += 1
|
||||
succ[len(neighborhood)-2] += new_partner_succ
|
||||
total[len(neighborhood)-2] += new_partner_request
|
||||
try:
|
||||
succ[len(neighborhood) - 2] += new_partner_succ
|
||||
total[len(neighborhood) - 2] += new_partner_request
|
||||
except:
|
||||
print("N!: %d" % len(neighborhood))
|
||||
|
||||
|
||||
|
||||
print(succ,total)
|
||||
# for classic
|
||||
succ = succ[4:]
|
||||
total = total[4:]
|
||||
|
||||
# for survival
|
||||
# succ = succ[:-1]
|
||||
# total = total[:-1]
|
||||
|
||||
red = '#d63031'
|
||||
fig = plt.figure(figsize=(6.4, 4))
|
||||
ax = fig.gca()
|
||||
@ -105,9 +118,9 @@ ax2.tick_params(axis='y', labelcolor=red)
|
||||
ax2.set_ylim(0,1)
|
||||
fig.tight_layout()
|
||||
# plt.show()
|
||||
# plt.savefig('graph/k_and_new_partner.eps')
|
||||
plt.savefig("graph/k_and_new_partner_%s.eps" % mode)
|
||||
|
||||
print("[succ vs k]pearson: %f, p-value: %f" % pearsonr(succ, k))
|
||||
print("[total vs k]pearson: %f, p-value: %f" % pearsonr(total, k))
|
||||
print("[rate vs k]pearson: %f, p-value: %f" % pearsonr(succ/total, k))
|
||||
print(np.average(succ/total))
|
||||
print(np.average(succ/total))
|
||||
|
||||
@ -73,3 +73,9 @@ wos-data-compete/G480.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G481.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G482.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G483.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G484.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G485.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G487.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G488.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G490.json,,LAB,,COMM,,CLASSIC
|
||||
wos-data-compete/G491.json,,LAB,,COMM,,CLASSIC
|
||||
|
121
rewiring_rate.py
121
rewiring_rate.py
@ -10,13 +10,66 @@ from matplotlib import markers
|
||||
def error(f,x,y):
|
||||
return sp.sum((f(x)-y)**2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
def p1(x, rewires, tau, postfix, show):
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
ax.plot(x, rewires, color=green, linewidth=3)
|
||||
ax.set_ylim(0, 0.5)
|
||||
ax2 = ax.twinx()
|
||||
ax2.plot(x, tau, color=red, linewidth=3)
|
||||
ax2.set_ylim(0, 1440)
|
||||
ax.set_xlim(1, 14)
|
||||
ax.set_xlabel("Rounds")
|
||||
ax.set_ylabel("Rewiring Rate", color=green)
|
||||
ax.tick_params(axis='y', labelcolor=green)
|
||||
ax2.set_ylabel("$\\tau_{p}$", family='sans-serif', color=red)
|
||||
ax2.tick_params(axis='y', labelcolor=red)
|
||||
|
||||
matches = Matches('wos-data-new-2')
|
||||
plt.tight_layout()
|
||||
if show:
|
||||
plt.show()
|
||||
else:
|
||||
plt.savefig("graph/tau_p_rewire_plot_%s.eps" % postfix)
|
||||
|
||||
def p2(tau, rewires, postfix, show):
|
||||
# # p2散点图
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
# ax.set_ylim(0.5, 1)
|
||||
fp1,residuals,rank,sv,rcond = sp.polyfit(tau, rewires, 1, full=True)
|
||||
print("残差:",residuals)
|
||||
print('Model parameter:',fp1)
|
||||
f1 = sp.poly1d(fp1)
|
||||
print("error= %f" % error(f1, tau, rewires))
|
||||
print("Other parameters: rank=%s, sv=%s, rcond=%s" % (str(rank), str(sv), str(rcond)))
|
||||
# fx = sp.linspace(0,max(tau2),1000)
|
||||
fx = sp.linspace(0,1440,2)
|
||||
|
||||
plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0)
|
||||
plt.scatter(tau, rewires, color=green, linewidths=2, zorder=100)
|
||||
# plt.scatter(tau_r, coopr_r, color='white', edgecolors=green, linewidths=2, zorder=101)
|
||||
ax.set_xlabel('$\\tau_{p}$', family='sans-serif')
|
||||
ax.set_ylabel('Rewiring Rate')
|
||||
ax.set_xlim(0, 1440)
|
||||
ax.set_xticks(sp.linspace(0, 1440, 13))
|
||||
ax.set_ylim(0, 0.6)
|
||||
plt.tight_layout()
|
||||
if show:
|
||||
plt.show()
|
||||
else:
|
||||
plt.savefig("graph/tau_p_rewire_sca_%s.eps" % postfix)
|
||||
|
||||
# 皮尔逊相关系数
|
||||
print("pearson: %f, p-value: %f" % pearsonr(tau, rewires))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mode = 'CLASSIC'
|
||||
matches = Matches.from_profile_expr(lambda r: mode in r)
|
||||
max_round = 15
|
||||
|
||||
survivals = {}
|
||||
with open('survivals-2.json', 'r') as f:
|
||||
with open('survivals.json', 'r') as f:
|
||||
survivals = json.load(f)
|
||||
|
||||
neighbors = {}
|
||||
@ -95,49 +148,21 @@ if __name__ == '__main__':
|
||||
red = '#d63031'
|
||||
|
||||
# p1折线图
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
ax.plot(x, rewires, color=green, linewidth=3)
|
||||
ax.set_ylim(0, 0.5)
|
||||
ax2 = ax.twinx()
|
||||
ax2.plot(x, tau, color=red, linewidth=3)
|
||||
ax2.set_ylim(0,1440)
|
||||
ax.set_xlim(1,14)
|
||||
ax.set_xlabel("Rounds")
|
||||
ax.set_ylabel("Rewiring Rate", color=green)
|
||||
ax.tick_params(axis='y', labelcolor=green)
|
||||
ax2.set_ylabel("$\\tau_{p}$", family='sans-serif', color=red)
|
||||
ax2.tick_params(axis='y', labelcolor=red)
|
||||
# p1(x, rewires, tau, mode, False)
|
||||
p2(tau, rewires, mode, False)
|
||||
|
||||
'''
|
||||
classic
|
||||
残差: [ 0.05873797]
|
||||
Model parameter: [ 9.81549075e-04 -9.87729952e-01]
|
||||
error= 0.058738
|
||||
Other parameters: rank=2, sv=[ 1.41291267 0.06064473], rcond=3.10862446895e-15
|
||||
pearson: 0.823000, p-value: 0.000300
|
||||
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
# plt.savefig('graph/tau_p_rewire_plot.eps')
|
||||
|
||||
# # p2散点图
|
||||
# fig = plt.figure(figsize=(6.4, 3.6))
|
||||
# ax = fig.gca()
|
||||
# # ax.set_ylim(0.5, 1)
|
||||
# fp1,residuals,rank,sv,rcond = sp.polyfit(tau, rewires, 1, full=True)
|
||||
# print("残差:",residuals)
|
||||
# print('Model parameter:',fp1)
|
||||
# f1 = sp.poly1d(fp1)
|
||||
# print("error= %f" % error(f1, tau, rewires))
|
||||
# # fx = sp.linspace(0,max(tau2),1000)
|
||||
# fx = sp.linspace(0,1440,2)
|
||||
|
||||
# plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0)
|
||||
# plt.scatter(tau, rewires, color=green, linewidths=2, zorder=100)
|
||||
# # plt.scatter(tau_r, coopr_r, color='white', edgecolors=green, linewidths=2, zorder=101)
|
||||
# ax.set_xlabel('$\\tau_{p}$', family='sans-serif')
|
||||
# ax.set_ylabel('Rewiring Rate')
|
||||
# ax.set_xlim(0, 1440)
|
||||
# ax.set_xticks(sp.linspace(0, 1440, 13))
|
||||
# ax.set_ylim(0, 0.6)
|
||||
# plt.tight_layout()
|
||||
# plt.show()
|
||||
# plt.savefig('graph/tau_p_rewire_sca.eps')
|
||||
|
||||
|
||||
|
||||
# # 皮尔逊相关系数
|
||||
print("pearson: %f, p-value: %f" % pearsonr(tau, rewires))
|
||||
survive
|
||||
残差: [ 0.05788203]
|
||||
Model parameter: [ 0.00033232 -0.06283898]
|
||||
error= 0.057882
|
||||
Other parameters: rank=2, sv=[ 1.3284034 0.48512309], rcond=3.10862446895e-15
|
||||
pearson: 0.893237, p-value: 0.000017
|
||||
'''
|
||||
|
||||
File diff suppressed because one or more lines are too long
145
tau_p_co.py
145
tau_p_co.py
@ -7,16 +7,83 @@ import scipy as sp
|
||||
from scipy.stats import pearsonr
|
||||
from matplotlib import markers
|
||||
|
||||
'''
|
||||
计算tau_p和合作频率之间的关系
|
||||
'''
|
||||
|
||||
def error(f,x,y):
|
||||
return sp.sum((f(x)-y)**2)
|
||||
|
||||
def p1(x, coopr, tau, postfix, show=True):
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
ax.plot(x, coopr, color=blue, linewidth=3)
|
||||
ax.set_ylim(0.5, 1)
|
||||
ax2 = ax.twinx()
|
||||
ax2.plot(x, tau, color=red, linewidth=3)
|
||||
ax2.set_ylim(0, 1440)
|
||||
ax.set_xlim(1, 14)
|
||||
ax.set_xlabel("Rounds")
|
||||
ax.set_ylabel("Frequency of Cooperation", color=blue)
|
||||
ax.tick_params(axis='y', labelcolor=blue)
|
||||
ax2.set_ylabel("$\\tau_{p}$", family='sans-serif', color=red)
|
||||
ax2.tick_params(axis='y', labelcolor=red)
|
||||
|
||||
plt.tight_layout()
|
||||
if show:
|
||||
plt.show()
|
||||
else:
|
||||
plt.savefig("graph/tau_p_co_plot_%s.eps" % postfix)
|
||||
|
||||
def p2(tau, coopr, limited, postfix, show=True):
|
||||
tau2 = []
|
||||
coopr2 = []
|
||||
tau_r = []
|
||||
coopr_r = []
|
||||
for i in range(len(tau)):
|
||||
if tau[i] <= limited:
|
||||
tau2.append(tau[i])
|
||||
coopr2.append(coopr[i])
|
||||
else:
|
||||
tau_r.append(tau[i])
|
||||
coopr_r.append(coopr[i])
|
||||
|
||||
# p2散点图
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
# ax.set_ylim(0.5, 1)
|
||||
fp1,residuals,rank,sv,rcond = sp.polyfit(tau2, coopr2, 1, full=True)
|
||||
print("残差:",residuals)
|
||||
print('Model parameter:',fp1)
|
||||
print("Other parameters: rank=%s, sv=%s, rcond=%s"%(str(rank), str(sv), str(rcond)))
|
||||
f1 = sp.poly1d(fp1)
|
||||
print("error= %f" % error(f1, tau2, coopr2))
|
||||
fx = sp.linspace(0, limited, 2)
|
||||
|
||||
plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0)
|
||||
plt.scatter(tau2, coopr2, color=blue, linewidths=2, zorder=100)
|
||||
plt.scatter(tau_r, coopr_r, color='white', edgecolors=blue, linewidths=2, zorder=101)
|
||||
ax.set_xlabel('$\\tau_{p}$', family='sans-serif')
|
||||
ax.set_ylabel('Frequency of Cooperation')
|
||||
ax.set_xlim(0, 1440)
|
||||
ax.set_xticks(sp.linspace(0, 1440, 13))
|
||||
ax.set_ylim(0.5, 1)
|
||||
plt.tight_layout()
|
||||
if show:
|
||||
plt.show()
|
||||
else:
|
||||
plt.savefig("graph/tau_p_co_sca_%s.eps" % postfix)
|
||||
|
||||
# 皮尔逊相关系数
|
||||
print("pearson: %f, p-value: %f" % pearsonr(tau2, coopr2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
matches = Matches('wos-data-new-3')
|
||||
matches = Matches.from_profile_expr(lambda r: 'SURVIVE' in r)
|
||||
max_round = 15
|
||||
|
||||
survivals = {}
|
||||
with open('survivals-3.json', 'r') as f:
|
||||
with open('survivals.json', 'r') as f:
|
||||
survivals = json.load(f)
|
||||
|
||||
neighbors = {}
|
||||
@ -101,65 +168,23 @@ if __name__ == '__main__':
|
||||
red = '#d63031'
|
||||
|
||||
# p1折线图
|
||||
# fig = plt.figure(figsize=(6.4, 3.6))
|
||||
# ax = fig.gca()
|
||||
# ax.plot(x, coopr, color=blue, linewidth=3)
|
||||
# ax.set_ylim(0.5, 1)
|
||||
# ax2 = ax.twinx()
|
||||
# ax2.plot(x, tau, color=red, linewidth=3)
|
||||
# ax2.set_ylim(0,1440)
|
||||
# ax.set_xlim(1,14)
|
||||
# ax.set_xlabel("Rounds")
|
||||
# ax.set_ylabel("Frequency of Cooperation", color=blue)
|
||||
# ax.tick_params(axis='y', labelcolor=blue)
|
||||
# ax2.set_ylabel("$\\tau_{p}$", family='sans-serif', color=red)
|
||||
# ax2.tick_params(axis='y', labelcolor=red)
|
||||
# p1(x, coopr, tau, 'survive', False)
|
||||
|
||||
# plt.tight_layout()
|
||||
# plt.show()
|
||||
# # plt.savefig('graph/tau_p_co_plot.eps')
|
||||
p2(tau[:12], coopr[:12], 720, 'survive', False)
|
||||
|
||||
tau2 = []
|
||||
coopr2 = []
|
||||
tau_r = []
|
||||
coopr_r = []
|
||||
tau3 = []
|
||||
coopr3 = []
|
||||
for i in range(len(tau)):
|
||||
if tau[i] <= 720:
|
||||
tau2.append(tau[i])
|
||||
coopr2.append(coopr[i])
|
||||
if tau[i] - 316 > 0.00001:
|
||||
tau3.append(tau[i])
|
||||
coopr3.append(coopr[i])
|
||||
|
||||
else:
|
||||
tau_r.append(tau[i])
|
||||
coopr_r.append(coopr[i])
|
||||
'''
|
||||
classic
|
||||
残差: [ 0.00317365]
|
||||
Model parameter: [ -1.24291981e-04 9.70766132e-01]
|
||||
Other parameters: rank=2, sv=[ 1.41276801 0.06392615], rcond=2.6645352591e-15
|
||||
error= 0.003174
|
||||
pearson: -0.607866, p-value: 0.036010
|
||||
|
||||
# p2散点图
|
||||
fig = plt.figure(figsize=(6.4, 3.6))
|
||||
ax = fig.gca()
|
||||
# ax.set_ylim(0.5, 1)
|
||||
fp1,residuals,rank,sv,rcond = sp.polyfit(tau2, coopr2, 1, full=True)
|
||||
print("残差:",residuals)
|
||||
print('Model parameter:',fp1)
|
||||
f1 = sp.poly1d(fp1)
|
||||
print("error= %f" % error(f1, tau2, coopr2))
|
||||
# fx = sp.linspace(0,max(tau2),1000)
|
||||
fx = sp.linspace(0,720,2)
|
||||
|
||||
plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0)
|
||||
plt.scatter(tau2, coopr2, color=blue, linewidths=2, zorder=100)
|
||||
plt.scatter(tau_r, coopr_r, color='white', edgecolors=blue, linewidths=2, zorder=101)
|
||||
ax.set_xlabel('$\\tau_{p}$', family='sans-serif')
|
||||
ax.set_ylabel('Frequency of Cooperation')
|
||||
ax.set_xlim(0, 1440)
|
||||
ax.set_xticks(sp.linspace(0, 1440, 13))
|
||||
ax.set_ylim(0.5, 1)
|
||||
plt.tight_layout()
|
||||
plt.show()
|
||||
# plt.savefig('graph/tau_p_co_sca.eps')
|
||||
|
||||
# 皮尔逊相关系数
|
||||
print("pearson: %f, p-value: %f" % pearsonr(tau2, coopr2))
|
||||
survive
|
||||
残差: [ 0.00548837]
|
||||
Model parameter: [ -2.71223484e-04 1.00851422e+00]
|
||||
Other parameters: rank=2, sv=[ 1.36321571 0.37635479], rcond=1.99840144433e-15
|
||||
error= 0.005488
|
||||
pearson: -0.829102, p-value: 0.005723
|
||||
'''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user