Skip to content
Extraits de code Groupes Projets
Valider b56db38f rédigé par Anzo's avatar Anzo
Parcourir les fichiers

prepared pipeline

parent dc7bcefc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Aucun aperçu pour ce type de fichier
......@@ -33,6 +33,8 @@ def ecdf_graph(N,RESOLUTION,seed,data):
xlabel= "Value"
ylabel="Cumulative Probability"
title_name= name +"\n N = "+str(N)+"\n seed = "+str(seed)
if N==0:
title_name= name +"\n seed = "+str(seed)
graph=sns.displot(data[name], kind="ecdf")
graph.set(title=title_name)
graph.set_axis_labels(xlabel,ylabel)
......
......@@ -57,9 +57,9 @@ def write_stats(data, name):
skew = scipy.stats.skew(data)
exckurt = scipy.stats.kurtosis(data) - 3
#write file
with open(name+'.csv', 'w', newline='') as csvfile:
with open('stats.csv', 'a', newline='') as csvfile:
datawriter = csv.DictWriter(csvfile, fieldnames=fields)
datawriter.writeheader()
#datawriter.writeheader()
datawriter.writerow({
"name" : name,
"quantil25" : str(quantil25),
......@@ -71,10 +71,26 @@ def write_stats(data, name):
"exckurt" : str(exckurt)})
return
def write_stats_chi(data, name, RES):
fields=["chi","p"]
val = stats.chisquared_uniform(data,RES)
chi = val[0]
p = val[1]
#write file
with open('chi.csv', 'a', newline='') as csvfile:
datawriter = csv.DictWriter(csvfile, fieldnames=fields)
#datawriter.writeheader()
datawriter.writerow({
"name" : name,
"chi" : str(chi),
"p" : str(p)})
return
if __name__=="__main__":
##INIT PARAMS##
N = 100
RESOLUTION = 1000
N = 1000000
RESOLUTION = 100
iterN = [100, 1000000, 100000000]
#init generators
generators = [ParkMiller(), KnuthLewis(), Marsaglia()
......@@ -87,7 +103,7 @@ if __name__=="__main__":
#set seaborn params
sns.set_theme(style="darkgrid")
#generate all diagrams
#generate N random values for each RNG
data = values(N,seed,generators)
#graph.hist_distributivity_graph(N,RESOLUTION,seed,data)
......@@ -96,8 +112,25 @@ if __name__=="__main__":
#graph.ecdf_graph(N,RESOLUTION,seed,data)
graph.compare(0, RESOLUTION, seed
, iteratives([1000, 10, 100], seed, ParkMiller()))
print(stats.chisquared_uniform(data["ParkMiller"],N))
print(np.quantile(data["ParkMiller"],0.25))
write_stats(data["ParkMiller"],"ParkMiller")
#graph.compare(0, RESOLUTION, seed
# , iteratives([1000, 10, 100], seed, ParkMiller()))
#print(stats.chisquared_uniform(data["ParkMiller"],RESOLUTION))
#print(np.quantile(data["ParkMiller"],0.25))
#write_stats(data["ParkMiller"],"ParkMiller")
#write_stats_chi(data["ParkMiller"], "ParkMiller", RESOLUTION)
#generate a lot of diagrams
graph.hist_distributivity_graph(N,RESOLUTION,seed,data)
for name in data:
write_stats(data[name],name)
write_stats_chi(data[name],name)
for name in generators:
data_iter = iteratives(iterN, seed, name)
graph.ecdf_graph(0, RESOLUTION, seed, data_iter)
graph.compare(0, RESOLUTION, seed, data_iter)
......@@ -5,15 +5,10 @@ Module to calculate various value on an array
import numpy as np
import scipy
def chisquared_uniform(arr, N):
def chisquared_uniform(arr,RES):
"""
chisquared for uniform distrib
"""
_,counts = np.unique(arr, return_counts=True)
observed_freq = counts/N
#print(observed_freq)
expected_freq = np.full(shape=observed_freq.size,fill_value=1/N)
print(observed_freq),print(expected_freq)
print(np.sum(expected_freq), np.sum(observed_freq))
return scipy.stats.chisquare(observed_freq, expected_freq)
observed_freq, _ = np.histogram(arr, bins=np.linspace(0,1,RES))
return scipy.stats.chisquare(observed_freq)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter