The sequence of tutorials show-cases the complete Python API of the Phasic library, a high-performance computational framework for modelling inference on waiting times in Markov jump processes. In addition to this introduction, the tutorial covers the following topics - in each as a jupyter notebook you can download and play with yourself.
Throughout the tutorials we use the Coalescent model as an example. The Coalescent is a continuous-time Markov chain that models the ancestry of a sample of individuals from a population. Lineages coalesce into fewer lineages with more descendants until only a single common ancestral lineage remains. Branches in the resulting tree represent lineages. We call those with a single sampled descendant singleton lineages. The ones with two descendants are doubletons and so on. With four samples, the Coalescent jumps with four singletons and terminates with a single quadrupleton (4’ton). We can encode the states of this Markov chain as vectors enumerating the number of of 1’tons, 2’tons, 3’tons, and 4’tons.
from phasic import Graph # ALWAYS import phasic first to set jax backend correctlyimport numpy as npimport seaborn as snsfrom vscodenb import set_vscode_themeset_vscode_theme()sns.set_palette('tab10')
Overriding theme from NOTEBOOK_THEME environment variable. <phasic._DeviceListFilter object at 0x17c3d1890>
Overriding theme from NOTEBOOK_THEME environment variable. <phasic._DeviceListFilter object at 0x17c3d1890>
Figure 1: The coalescent process with four samples. The S (starting) state just signifies that the process begins in state (4,0,0,0). Edges are annotated with the coalescence rates that, in this model represents the transition rates of the model
If you can think of your favorite Markov model in this way, phasic does the rest for you.