What are State Space Models?
Contents
{
"tags": [
"hide-cell"
]
}
### Install necessary libraries
try:
import jax
except:
# For cuda version, see https://github.com/google/jax#installation
%pip install --upgrade "jax[cpu]"
import jax
try:
import jsl
except:
%pip install git+https://github.com/probml/jsl
import jsl
try:
import rich
except:
%pip install rich
import rich
{
"tags": [
"hide-cell"
]
}
### Import standard libraries
import abc
from dataclasses import dataclass
import functools
import itertools
from typing import Any, Callable, NamedTuple, Optional, Union, Tuple
import matplotlib.pyplot as plt
import numpy as np
import jax
import jax.numpy as jnp
from jax import lax, vmap, jit, grad
from jax.scipy.special import logit
from jax.nn import softmax
from functools import partial
from jax.random import PRNGKey, split
import inspect
import inspect as py_inspect
from rich import inspect as r_inspect
from rich import print as r_print
def print_source(fname):
r_print(py_inspect.getsource(fname))
What are State Space Models?¶
A state space model or SSM is a partially observed Markov model, in which the hidden state, \(z_t\), evolves over time according to a Markov process.
Fig. 3 Illustration of an SSM as a graphical model.¶
Fig. 4 Illustration of a simplified SSM.¶
Example: Casino HMM¶
We first create the “Ocassionally dishonest casino” model from [DEKM98].
There are 2 hidden states, each of which emit 6 possible observations.
# state transition matrix
A = np.array([
[0.95, 0.05],
[0.10, 0.90]
])
# observation matrix
B = np.array([
[1/6, 1/6, 1/6, 1/6, 1/6, 1/6], # fair die
[1/10, 1/10, 1/10, 1/10, 1/10, 5/10] # loaded die
])
pi, _ = normalize(np.array([1, 1]))
pi = np.array(pi)
(nstates, nobs) = np.shape(B)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-2f308bef5393> in <module>
11 ])
12
---> 13 pi, _ = normalize(np.array([1, 1]))
14 pi = np.array(pi)
15
NameError: name 'normalize' is not defined