Files
2026-06-15 10:31:58 +02:00

58 lines
1.2 KiB
Python

#!/usr/bin/env python3
from argparse import ArgumentParser
from monobit_test import monobit_test
import matplotlib.pyplot as plt
from math import ceil
parser = ArgumentParser(description="Stats")
parser.add_argument('-r', '--random', help='Random tests file')
args = parser.parse_args()
if args.random is None:
print("You must specify the random test file")
exit(-1)
data = None
with open(args.random, "r") as f:
data = f.readlines()
x = list()
y = list()
i = 0
totals = 0
totalsAverage = dict()
for entry in data:
rand = int(entry.replace("\n", ""))
stats = monobit_test(bin(rand)[2:])
totals += 1
# Je recupere juste le la value 0.x et je fais une moyenne
pvalue = str(stats)[0:3]
print(f"{rand}: {stats}: {pvalue}")
if pvalue not in totalsAverage:
totalsAverage[pvalue] = 0
totalsAverage[pvalue] += 1
y.append(stats) # Get the maximum value
x.append(i)
i += 1
plt.figure(figsize=(10, 6))
plt.bar(x, y, color='b')
plt.legend()
plt.show()
x = list()
y = list()
for entry in totalsAverage:
print(f"{entry}: {totalsAverage[entry]}")
x.append(entry)
y.append(totalsAverage[entry])
plt.figure(figsize=(10, 6))
plt.bar(x, y, color='b')
plt.legend()
plt.show()