Kleine Anpassungen
parent
0c6cf3661b
commit
9b7af12c8e
|
@ -28,61 +28,59 @@ class StartUPTest:
|
||||||
p_value = erfc(fabs(sObs) / sqrt(2))
|
p_value = erfc(fabs(sObs) / sqrt(2))
|
||||||
|
|
||||||
# return a p_value and randomness result
|
# return a p_value and randomness result
|
||||||
return (p_value, (p_value >= 0.01))
|
return p_value, (p_value >= 0.01)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def test5(binary_data: str):
|
def autocorrelation_test(binary_data: str):
|
||||||
|
|
||||||
ShiftFeld = [0] * 5000
|
shift_feld = [0] * 5000
|
||||||
MaxKorrFeld = [0] * 5000
|
max_korr_feld = [0] * 5000
|
||||||
|
|
||||||
# Fill BitFeldB with data
|
# Fill BitFeldB with data
|
||||||
|
|
||||||
for tau in range(1, 5001):
|
for tau in range(1, 5001):
|
||||||
Z_tau = 0
|
z_tau = 0
|
||||||
for i in range(5000):
|
for i in range(5000):
|
||||||
Z_tau += binary_data[i] ^ binary_data[i + tau]
|
z_tau += binary_data[i] ^ binary_data[i + tau]
|
||||||
ShiftFeld[tau - 1] = Z_tau
|
shift_feld[tau - 1] = z_tau
|
||||||
|
|
||||||
#Debugging
|
# Debugging
|
||||||
#for i in range(5000):
|
# for i in range(5000):
|
||||||
# print(ShiftFeld[i], end=' ')
|
# print(shift_feld[i], end=' ')
|
||||||
|
|
||||||
# Find the index of the maximum deviation from 2500
|
# Find the index of the maximum deviation from 2500
|
||||||
max_deviation = 0
|
max_deviation = 0
|
||||||
for tau in range(5000):
|
for tau in range(5000):
|
||||||
deviation = abs(ShiftFeld[tau] - 2500)
|
deviation = abs(shift_feld[tau] - 2500)
|
||||||
if deviation > max_deviation:
|
if deviation > max_deviation:
|
||||||
max_deviation = deviation
|
max_deviation = deviation
|
||||||
|
|
||||||
# Find all indices with the maximum deviation
|
# Find all indices with the maximum deviation
|
||||||
j = 0
|
j = 0
|
||||||
for tau in range(5000):
|
for tau in range(5000):
|
||||||
deviation = abs(ShiftFeld[tau] - 2500)
|
deviation = abs(shift_feld[tau] - 2500)
|
||||||
if deviation == max_deviation:
|
if deviation == max_deviation:
|
||||||
MaxKorrFeld[j] = tau
|
max_korr_feld[j] = tau
|
||||||
j += 1
|
j += 1
|
||||||
|
|
||||||
print("Maximale Z_tau-Abweichung von 2500:", max_deviation)
|
print("Maximale z_tau-Abweichung von 2500:", max_deviation)
|
||||||
print("Aufgetreten für Shifts:")
|
print("Aufgetreten für Shifts:")
|
||||||
for k in range(j):
|
for k in range(j):
|
||||||
print("Shift:", MaxKorrFeld[k] + 1)
|
print("Shift:", max_korr_feld[k] + 1)
|
||||||
|
|
||||||
tau = MaxKorrFeld[0]
|
tau = max_korr_feld[0]
|
||||||
Z_tau = 0
|
z_tau = 0
|
||||||
for i in range(10000, 15000):
|
for i in range(10000, 15000):
|
||||||
Z_tau += StartUPTest.charToInt(i, binary_data) ^ StartUPTest.charToInt(i + tau + 1, binary_data)
|
z_tau += StartUPTest.char_to_int(i, binary_data) ^ StartUPTest.char_to_int(i + tau + 1, binary_data)
|
||||||
tau += 1
|
tau += 1
|
||||||
|
|
||||||
ok = Z_tau > 2326 and Z_tau < 2674
|
ok = 2326 < z_tau < 2674
|
||||||
return (Z_tau, ok)
|
return z_tau, ok
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def charToInt(index, binary_data: str):
|
def char_to_int(index, binary_data: str):
|
||||||
value = 0
|
|
||||||
if binary_data[index] == 49:
|
if binary_data[index] == 49:
|
||||||
value = 1
|
value = 1
|
||||||
else:
|
else:
|
||||||
value = 0
|
value = 0
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue