Discrete HMMs
cuthbertlib.discrete.filtering
Implements the discrete HMM filtering associative operator.
FilterScanElement
Bases: NamedTuple
Elements carried through the discrete HMM filtering scan.
f
instance-attribute
log_g
instance-attribute
condition_on_obs(state_probs, log_likelihoods)
Conditions a state distribution on an observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_probs
|
Array
|
Either the state transition probabilities or the initial distribution. |
required |
log_likelihoods
|
Array
|
Vector of \(\log p(y_t \mid x_t)\) for each possible state \(x_t\). |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array]
|
The conditioned state and the log normalizing constant. |
Source code in cuthbertlib/discrete/filtering.py
filtering_operator(elem_ij, elem_jk)
Binary associative operator for filtering in discrete HMMs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elem_ij
|
FilterScanElement
|
Filter scan element. |
required |
elem_jk
|
FilterScanElement
|
Filter scan element. |
required |
Returns:
| Type | Description |
|---|---|
FilterScanElement
|
The output of the associative operator applied to the input elements. |
Source code in cuthbertlib/discrete/filtering.py
cuthbertlib.discrete.smoothing
Implements the discrete HMM smoothing associative operator.
get_reverse_kernel(x_t_dist, trans_matrix)
Computes reverse transition probabilities \(p(x_{t-1} \mid x_{t}, \dots)\) for a discrete HMM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_t_dist
|
ArrayLike
|
Array of shape (N,) where |
required |
trans_matrix
|
ArrayLike
|
Array of shape (N, N) where
|
required |
Returns:
| Type | Description |
|---|---|
Array
|
An (N, N) matrix |
Source code in cuthbertlib/discrete/smoothing.py
smoothing_operator(elem_ij, elem_jk)
Binary associative operator for smoothing in discrete HMMs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elem_ij
|
Array
|
Smoothing scan element. |
required |
elem_jk
|
Array
|
Smoothing scan element. |
required |
Returns:
| Type | Description |
|---|---|
Array
|
The output of the associative operator applied to the input elements. |