Skip to content

Instantly share code, notes, and snippets.

View olafx's full-sized avatar

Olaf Willocx olafx

View GitHub Profile
@olafx
olafx / E8_8_ball.py
Created May 12, 2025 11:29
8 ball volume integration via optimal packing in 8 dimensions using the E8 lattice (this is silly and doesn't work well)
import itertools
import math
def gen_E8_lattice(L):
for x in itertools.product(range(-L, L+1), repeat=8):
if sum(x) % 2 == 0:
yield x
for x in itertools.product(range(-L, L+1), repeat=8):
half = [xi + 0.5 for xi in x]
if sum(half) % 2 == 0:
@olafx
olafx / MH_autocorr_1.py
Created March 26, 2025 09:00
Metropolis-Hastings autocorrelation
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import RegularGridInterpolator
plt.rcParams['font.size'] = 14
plt.rcParams['figure.figsize'] = (5, 4)
plt.rcParams['text.usetex'] = True
n = 100
N = int(1e5)
@olafx
olafx / dataframe.cpp
Created December 25, 2024 20:06
Proof of concept dataframe with compile time string column names and types
#include <vector>
#include <string>
#include <tuple>
#include <print>
template <size_t n, typename A, typename ...B>
size_t nth(A a, B... b)
{ if constexpr (n == 0)
return a;
else