-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstats.py
More file actions
46 lines (35 loc) · 1.2 KB
/
stats.py
File metadata and controls
46 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
Created on Wed May 11 14:11:24 2016
@author: Maxime
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
def statsRead(n=10):
try:
with open("res/" + "stats_n=" + str(n) + ".txt", 'r') as fichier:
lines = fichier.readlines()
temps, nb_mvts = [], []
for l in lines:
data = l.split()
temps.append(float(data[0]))
nb_mvts.append(int(data[1]))
except FileNotFoundError:
print("Le fichier stats_n={} est introuvable.".format(n))
else:
return temps, nb_mvts
def stats(data):
n = len(data)
mu, std = norm.fit(data)
X = np.linspace(min(data), max(data), n)
Y = norm.pdf(X, mu, std) * n
plt.hist(data, bins = n)
#plt.plot(X,Y, label = "$\mu={}$\n$\sigma={}$\n$min = {}$\n$max = {}$".format(int(mu),int(std*10)/10, min(data), max(data)))
plt.legend(loc = 'upper right')
plt.xlabel("Temps d'exécution en secondes")
plt.ylabel("Fréquence * {}".format(n))
plt.title("Histogramme du temps d'exécution sur {} résolutions ".format(n))
plt.show()
temps, nb_mvts = statsRead(1000)
stats(temps)