Commit 18bd67ed authored by Grégoire Grzeczkowicz's avatar Grégoire Grzeczkowicz
Browse files

Add label

parent 633ddf25
...@@ -33,7 +33,7 @@ if __name__=="__main__": ...@@ -33,7 +33,7 @@ if __name__=="__main__":
for i in range(the.nb_run): for i in range(the.nb_run):
print("\rRun {}".format(i), end = '') print("\rRun {}".format(i), end = '')
system("python3 snp.py -o run -no "+" ".join(arg[1])) system("python3 snp.py -o run -no -s " + str(np.random.randint(0, 10*the.nb_run)) + " "+" ".join(arg[1]))
print("\r") print("\r")
# Data extraction # Data extraction
...@@ -70,7 +70,7 @@ if __name__=="__main__": ...@@ -70,7 +70,7 @@ if __name__=="__main__":
for attempt in data: for attempt in data:
good = False good = False
for t,v in attempt.items(): for t,v in attempt.items():
if t < time and v > value: if t <= time and v >= value:
good = True good = True
break break
if good: if good:
...@@ -84,19 +84,33 @@ if __name__=="__main__": ...@@ -84,19 +84,33 @@ if __name__=="__main__":
with open('proba.json', 'w') as outfile: with open('proba.json', 'w') as outfile:
json.dump(data, outfile) json.dump(data, outfile)
elif the.for_value is not None: elif the.for_value is not None:
temps = np.linspace(0,temps_max,100) P = probability(data,range(1,temps_max+1),the.for_value)
P = probability(data,temps,the.for_value) plt.bar(range(1,temps_max+1), P)
plt.plot(temps,P) plt.title("ERT for target {}".format(the.for_value))
plt.xlabel('run')
plt.ylabel('probability')
plt.ylim(0,1)
plt.show() plt.show()
else: else:
temps = np.linspace(0,temps_max,100) temps = range(0,temps_max+2)
values = np.linspace(0,value_max,100) values = range(0,int(value_max+2))
X, Y = np.meshgrid(temps, values) X, Y = np.meshgrid(temps, values)
Z = probability(data,X,Y) Z = probability(data,X,Y)
print(Z)
"""
fig, ax = plt.subplots() fig, ax = plt.subplots()
cs = ax.contourf(X, Y, Z, 20) cs = ax.contourf(X, Y, Z, 20)
cbar = fig.colorbar(cs) cbar = fig.colorbar(cs)
"""
proba = np.linspace(0.0, 1.0, 11)
cs = plt.contourf(X, Y, Z, levels=proba)
cbar = plt.colorbar(cs)
cbar.set_label('probability')
plt.xlabel('run')
plt.ylabel('target')
plt.show() plt.show()
#remove('run.csv') #remove('run.csv')
...@@ -41,7 +41,7 @@ def probability(data,time,value): ...@@ -41,7 +41,7 @@ def probability(data,time,value):
for attempt in data: for attempt in data:
good = False good = False
for t,v in attempt.items(): for t,v in attempt.items():
if int(t) < time and v > value: if int(t) <= time and v >= value:
good = True good = True
break break
if good: if good:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment