markovflow.emission_model
Module containing emission models for projection.
EmissionModel
Takes output from StateSpaceModel methods and linearly projects it into a space of dimension \(m\) (output_dim):
StateSpaceModel
output_dim
This class provides methods for projecting states or covariances, sampling and calculating the marginals.
emission_matrix – The emission matrix that projects at each time point from the StateSpaceModel, with shape batch_dim + [num_data, output_dim, state_dim].
batch_dim + [num_data, output_dim, state_dim]
batch_shape
Return the shape of any leading dimension in the emission matrix that comes before the last three.
num_data
Return the number of time points that the emission matrix is applied to.
Return the dimension of the output after the emission matrix is applied.
state_dim
Return the state dimension of the StateSpaceModel we emit from.
emission_matrix
Return the emission matrix.
A tensor for the emission matrix, with shape batch_dim + [num_data, output_dim, state_dim].
project_state_marginals_to_f
Project the marginal mean and covariance of states to get means and (co)variance of \(f\).
means – A tensor of means with shape batch_shape + [num_data, state_dim].
batch_shape + [num_data, state_dim]
covariances – A tensor of covariances with shape batch_shape + [num_data, state_dim, state_dim].
batch_shape + [num_data, state_dim, state_dim]
full_output_cov – Full output covariance (True) or marginal variances (False).
True
False
The means and covariances with respective shapes batch_shape + [num_data, output_dim], and either batch_shape + [num_data, output_dim, output_dim] or batch_shape + [num_data, output_dim].
batch_shape + [num_data, output_dim]
batch_shape + [num_data, output_dim, output_dim]
project_state_to_f
Project a state to \(f\) by multiplying by \(H\).
state – A tensor with shape batch_shape + [num_data, state_dim].
A tensor with shape batch_shape + [num_data, output_dim].
project_state_covariance_to_f
Project a state covariance \(S\) to an \(f\) covariance by calculating \(HSHᵀ\) (or its diagonal).
covariance – A tensor with shape batch_shape + [num_data, state_dim, state_dim].
A tensor either with shape batch_shape + [num_data, output_dim, output_dim] or batch_shape + [num_data, output_dim].
ComposedPairEmissionModel
Bases: EmissionModel
Linear projection for use with kernels that have an intermediate projection. That is, there exists a projection from the state space to an intermediate space, and from that space to the observation space:
This class provides methods for projecting states or covariances, sampling and calculating the marginals, from state space to both the observation and intermediate space.
outer_emission_model – The emission model for projecting from the intermediate space to the observation space.
inner_emission_model – The emission model for projecting from state space to the intermediate space.
inner_dim
Return the output dimension of the inner emission model.
inner_emission_matrix
Return the emission matrix used for projecting from the state space to the intermediate space.
A tensor for the emission matrix, with shape batch_dim + [num_data, inner_dim, state_dim].
batch_dim + [num_data, inner_dim, state_dim]
project_state_marginals_to_g
Project the marginal mean and covariance of states to get means for \(g\).
The means and covariances with respective shapes batch_shape + [num_data, inner_dim], and either batch_shape + [num_data, inner_dim, inner_dim] or batch_shape + [num_data, inner_dim].
batch_shape + [num_data, inner_dim]
batch_shape + [num_data, inner_dim, inner_dim]
project_state_to_g
Project a state to \(g\) by multiplying by the inner emission matrix.
A tensor with shape batch_shape + [num_data, inner_dim].
project_state_covariance_to_g
Project a state covariance \(S\) to a \(g\) covariance by calculating \(HSHᵀ\) with the inner \(H\).
A tensor either with shape batch_shape + [num_data, inner_dim, inner_dim] or batch_shape + [num_data, inner_dim].
StackEmissionModel
Linear projection for use with a StackKernel, where we implicitly assume that we have parallel independent SDEs that model each one of the output dimensions.
StackKernel
In such a scenario we assume that the \(m\) (output_dim) independent SDEs can be broadcast together so the output_dim is part of the batch_shape (last dim in the batch_shape).
So the emission matrix that defines the StackEmissionModel has the following shape:
batch_shape + [num_data, 1, state_dim]
…where batch_shape = (..., num_kernels) and num_kernels = output_dim. The singleton pre-last dimension is for the individual output_dim of each kernel. Remember that each kernel explicitly models one of the output dimensions.
batch_shape = (..., num_kernels)
num_kernels = output_dim
We effectively run \(m\) (output_dim) independent SDEs as follows:
This class provides methods for projecting states or covariances and calculating the marginals from the state space to the observation space. It is acting as the base EmissionModel class with an extra transposition in the end to make sure that the output_dim gets moved from the batch_shape to the last dim of the projected matrices.
emission_matrix – The emission matrix that projects from the StateSpaceModel, with shape batch_shape + [num_data, 1, state_dim] where batch_shape = (..., num_kernels).
Project each of the num_kernel states \(s\) to \(f\) by multiplying by the corresponding \(H\).
num_kernel
state – A tensor with shape batch_shape + [num_data, state_dim] where batch_shape = (..., num_kernels) and num_kernels = output_dim.
A tensor with shape batch_shape[:-1] + [num_data, output_dim].
batch_shape[:-1] + [num_data, output_dim]
Project a state covariance \(S\) to an \(f\) covariance by calculating \(HSHᵀ\) (or its diagonal). If it is called with full_output_cov=True it will return the same as full_output_cov=False but in a compatible (diagonal) shape.
full_output_cov=True
full_output_cov=False
covariance – A tensor with shape batch_shape + [num_data, state_dim, state_dim] where batch_shape = (..., num_kernels) and num_kernels = output_dim
A tensor either with shape batch_shape[:-1] + [num_data, output_dim, output_dim] or batch_shape[:-1] + [num_data, output_dim].
batch_shape[:-1] + [num_data, output_dim, output_dim]