Skip to content

Instantly share code, notes, and snippets.

View THargreaves's full-sized avatar
🎲
Striving to make a statistically significant difference in the world

Tim Hargreaves THargreaves

🎲
Striving to make a statistically significant difference in the world
View GitHub Profile
@THargreaves
THargreaves / rao_blackwellisation_prototype.jl
Created April 30, 2024 16:21
A combined proposal for multiple enhancements to the SSMProblems.jl interface that lead to a clean API for Rao-Blackwellised filtering
"""
This script contains a combined proposal for multiple enhancements to the existing
SSMProblems.jl interface that we have discussed over the past few months. The main
features are:
- Separation of latent dynamics and observation processes
- Introduction of control variables
- Unified interface for defining linear Gaussian models
- Interface for forward simulation and conditioning
- Hierarchical (conditional) latent dynamics
- Rao-Blackwellised filtering
@THargreaves
THargreaves / fake_letter_friends.r
Last active December 26, 2021 19:35
Which letter pairs that are next to each other in the alphabet actually appear together in the English language?
library(janeaustenr)
library(tidytext)
library(tidyverse)
theme_set(theme_bw())
cleaned_words <- austen_books() |>
unnest_tokens(word, text) |>
# Remove roman numerals
filter(!str_detect(word, "[IVXLCDM]+")) |>
#!/usr/bin/env python
"""schedule.py: Meeting scheduler based on Ford–Fulkerson algorithm.
A tool to generate or prove the lack of existance of a schedule for one-on-one
meetings given the availabilities of attendees for different time slots.
The solution is based on a modification of the Ford-Fulkerson algorithm in
which edge capacities are binary. By converting the the availability matrix
into a bipartite graph with edges of capacity one and introducing source and
@THargreaves
THargreaves / christmas_tree.py
Last active December 23, 2023 22:14
Generate an animated Christmas tree with Python
# -*- coding: utf-8 -*-
"""
@author: Tim Hargreaves
"""
# see write-up at www.ttested.com/coding-up-christmas/ for more detail
from random import uniform
import matplotlib.animation as ani