markovflow.kernels.piecewise_stationary
Module containing a piecewise stationary kernel.
PiecewiseKernel
Bases: markovflow.kernels.sde_kernel.NonStationaryKernel
markovflow.kernels.sde_kernel.NonStationaryKernel
Construct an SDE kernel whose state dynamic is governed by different SDEs. These are on the \(K+1\) intervals specified by the \(K\) change points \(cₖ\).
On interval \([cₖ, cₖ₊₁]\), the dynamics are governed by a SDE kernel \(kₖ\) where \(c₀ = -∞\):
Note the following:
This is currently restricted to cases where the kernels are the same. State space models constructed by marginalizing out the process to time points \(t\) are only valid if no transitions cross a change point.
This is currently restricted to cases where the kernels are the same.
State space models constructed by marginalizing out the process to time points \(t\) are only valid if no transitions cross a change point.
kernels – An iterable over the kernels forming this kernel.
change_points – Sorted change points.
output_dim – The output dimension of the kernel.
jitter – A small non-negative number to add into a matrix’s diagonal to maintain numerical stability during inversion.
state_dim
Return the state dimension of the generated StateSpaceModel.
StateSpaceModel
generate_emission_model
Generate the EmissionModel associated with this kernel that maps from the latent StateSpaceModel to the observations.
EmissionModel
The emission matrix is the Kronecker product of all the children emission matrices.
time_points – The time points over which the emission model is defined, with shape batch_shape + [num_data].
batch_shape + [num_data]
initial_covariance
Return the initial covariance of the generated StateSpaceModel.
This is the covariance of the stationary distribution \(P∞\) for the kernel active at the time passed in.
initial_time_point – The time point associated with the first state, with shape batch_shape + [1,].
batch_shape + [1,]
A tensor with shape batch_shape + [state_dim, state_dim].
batch_shape + [state_dim, state_dim]
split_time_indices
Gives each time point an index that refers to which interval it resides in.
The sub-kernel that governs the SDE is different on different sub intervals, as specified by the change points.
If there are \(K\) change points, then \(0\) is the index before the first change point and \(K + 1\) is the index after the last change point.
time_points – A tensor with shape batch_shape + [num_time_points].
batch_shape + [num_time_points]
A tensor of indices in range 0 - num_change_points, with shape batch_shape + [num_time_points].
num_change_points
split_input
Partitions input_tensor into regions determined by the change points.
input_tensor
input_tensor – An arbitrary input tensor, with shape batch_shape + [N].
batch_shape + [N]
indices – The index for each input of the input tensor, with shape batch_shape + [N].
A list of tensors each with shape batch_shape + [Nₖ], where \((Σₖ Nₖ = N)\).
batch_shape + [Nₖ]
steady_state_covariances
For each time point, return the steady state covariance of the kernel active for that time point.
The steady state covariance at each time point, with shape batch_shape + [num_time_points, state_dim, state_dim].
batch_shape + [num_time_points, state_dim, state_dim]
state_transitions
Return the state transition matrices of the generated StateSpaceModel \(Aₖ = exp(FΔtₖ)\).
Note
Transitions are only valid if they do not cross a change point.
transition_times – Time points at which to produce matrices, with shape batch_shape + [num_transitions].
batch_shape + [num_transitions]
time_deltas – Time gaps for which to produce matrices, with shape batch_shape + [num_transitions].
A tensor with shape batch_shape + [num_transitions, state_dim, state_dim].
batch_shape + [num_transitions, state_dim, state_dim]
transition_statistics
Return state_transitions() and process_covariances() together to save having to compute them twice.
state_transitions()
process_covariances()
transition_times – A tensor of times at which to produce matrices, with shape batch_shape + [num_transitions].
time_deltas – A tensor of time gaps for which to produce matrices, with shape batch_shape + [num_transitions].
A tuple of two tensors, with respective shapes batch_shape + [num_transitions, state_dim, state_dim]. batch_shape + [num_transitions, state_dim, state_dim].
feedback_matrices
For each time point, return the non-stationary feedback matrix \(F(t)\) of the kernel active for that time point.
The feedback matrix at each time point, with shape batch_shape + [num_time_points, state_dim, state_dim].
state_offsets
Return the state offsets \(bₖ\) of the generated StateSpaceModel.
This will usually be zero, but can be overridden if necessary. :param transition_times: A tensor of times at which to produce matrices, with shape
batch_shape + [num_transitions].
A tensor with shape batch_shape + [num_transitions, state_dim]
batch_shape + [num_transitions, state_dim]
state_means
For each time point, return the state mean of the kernel active for that time point.
The state mean at each time point batch_shape + [num_time_points, state_dim].
batch_shape + [num_time_points, state_dim]