Skip to content

Instantly share code, notes, and snippets.

View swo's full-sized avatar

Scott Olesen swo

View GitHub Profile
@swo
swo / xkcd.py
Last active December 10, 2024 19:01
XKCD 3015
from sympy import *
import functools
a, b, z = var('a b z')
# discrete uniform pgf
G_du = (z ** a - z ** (b + 1)) / ((b - a + 1) * (1 - z))
# pgf for 3d6 + 1d4
G = G_du.subs(a, 1).subs(b, 6) ** 3 * G_du.subs(a, 1).subs(b, 4)
@swo
swo / my_curve.py
Created April 4, 2025 15:35
Two-part logistic
import altair as alt
import numpy as np
import polars as pl
import streamlit as st
def logistic(x, y0, scale, x0, k):
return y0 + scale / (1 + np.exp(-k * (x - x0)))
@swo
swo / streamlit_example.py
Created May 7, 2025 13:42
Streamlit example
import streamlit as st
import re
st.title("A regex checker")
s = st.text_input("string")
r = re.compile(st.text_input("regex"))
st.write(re.findall(string=s, pattern=r))