Skip to content

Instantly share code, notes, and snippets.

View honno's full-sized avatar
🛰️

Matthew Barber honno

🛰️
View GitHub Profile
@honno
honno / randtests_refimpl.py
Created November 14, 2020 14:25
Reference implementation of the SP800-22 randomness tests
from collections import Counter
from collections import defaultdict
from itertools import accumulate
from itertools import product
from math import erfc
from math import floor
from math import log
from math import log2
from math import sqrt
from typing import Iterator
@honno
honno / store.py
Created October 22, 2020 07:31
coinflip's old store module
"""Store functionality for the CLI
Notes
-----
A store is an abstraction for a folder in the user's local data directory
which pertains to a specific dataset that comprises of RNG output. The store can
subsequently store test results and report markup for said results.
"""
import pickle
import shelve
@honno
honno / berlekamp_massey.py
Last active September 30, 2020 17:25
GF(2) variant of the Berlekamp-Massey algorithm, i.e. for binary sequences (a list of zero and one integers)
from copy import copy
def berlekamp_massey(sequence: List[int]) -> int:
n = len(sequence)
error_locator = [0 for _ in range(n)]
error_locator[0] = 1
error_locator_prev = copy(error_locator)
@honno
honno / data.txt
Last active July 13, 2020 09:06
Example random data
1
0
1
0
1
0
1
1
1
0
@honno
honno / scotland_ yard.tex
Last active July 12, 2020 14:29
Old coursework submission
\title{Representing Scotland Yard with data structures, and using Computational Thinking to determine Mr X's location}
\author{Matthew Barber\\
160056525}
\date{\today}
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{calc}
@honno
honno / time-sheet.svg
Created July 12, 2020 12:17
Sheet I use for time management
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@honno
honno / org_minted_export.elisp
Created July 12, 2020 11:37
Quick fix for org not exporting minted latex correctly
(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
"pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"))
@honno
honno / example_profile.py
Last active July 17, 2020 18:25
profiling concept for rngtest
import pandas as pd
from rngtest.profiling import profile, multi_profile
def get_columns(df):
for col in df:
yield df[col]
@profile
@honno
honno / longest_runs.ipynb
Created June 18, 2020 12:50
Related observations on NIST's longest runs test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python2
from collections import defaultdict
import Queue
DIRECTIONS = [(-1, 0), (0, 1), (1, 0), (0, -1)]
FREE, WALL = 0, 1
class OutOfMapBoundaryError(Exception):
pass