Skip to content

Instantly share code, notes, and snippets.

View ihh's full-sized avatar

Ian Holmes ihh

View GitHub Profile
@ihh
ihh / hmm.py
Last active February 7, 2024 20:15
Forward algorithm for HMM using jax scans
import jax
import jax.numpy as jnp
from jax.scipy.special import logsumexp
# Implements the Forward algorithm for an HMM as a scan (both generic and associative).
# Inputs:
# t[i,j] = transition probability from state i to state j
# e[i,o] = probability of emitting observation o from state i
# start[i] = initial probability of state i (transitions from start state)
# end[i] = probability of ending from state i (transitions to end state)
# emacs mode -*-makefile-*-
# Database downloaded from the FBTEE project, University of Western Sydney.
# FBTEE: The French Book Trade in Enlightenment Europe
# http://fbtee.uws.edu.au/
# EULA for database available here:
# http://fbtee.uws.edu.au/main/eula/