Last active
September 19, 2017 18:51
-
-
Save breuderink/733e2f8d626869ccde3520cdba530bde to your computer and use it in GitHub Desktop.
The hunt for the most normal scrambler for SORM features.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy import linalg, stats | |
import numpy as np | |
from functools import reduce | |
N = 16 | |
def eval_scrambler(pat, reps=1): | |
pat = np.atleast_1d(pat) | |
D = np.diag(np.where(pat==1, -1, 1)) | |
H = linalg.hadamard(pat.size) | |
return reduce(np.dot, [H] + [D, H] * reps) | |
best = -np.inf | |
perfs = [] | |
for i in range(0, 1<<N): | |
pat = np.asarray([(i >> b) & 1 for b in range(N)]) | |
T = eval_scrambler(pat, reps=2) | |
vals = np.unique(T) | |
(_, perf) = stats.shapiro(T.flatten()) | |
perfs.append(perf) | |
if perf > best: | |
best = perf | |
print('%s -> %s' % (pat, perf)) | |
print(stats.itemfreq(perfs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment