markovflow.kernels.piecewise_stationary

Module containing a piecewise stationary kernel.

Module Contents

class PiecewiseKernel(kernels: List[markovflow.kernels.sde_kernel.StationaryKernel], change_points: gpflow.base.TensorType, output_dim: int = 1, jitter: float = 0.0)[source]

Bases: 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₀ = -∞\):

\[\begin{split}&dx(t)/dt = Fₖ x(t) + Lₖ w(t),\\ &f(t) = Hₖ x(t)\end{split}\]

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.

Parameters
  • 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.

property state_dimint[source]

Return the state dimension of the generated StateSpaceModel.

generate_emission_model(time_points: tf.Tensor)markovflow.emission_model.EmissionModel[source]

Generate the EmissionModel associated with this kernel that maps from the latent StateSpaceModel to the observations.

The emission matrix is the Kronecker product of all the children emission matrices.

Parameters

time_points – The time points over which the emission model is defined, with shape batch_shape + [num_data].

initial_covariance(initial_time_point: tf.Tensor)tf.Tensor[source]

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.

Parameters

initial_time_point – The time point associated with the first state, with shape batch_shape + [1,].

Returns

A tensor with shape batch_shape + [state_dim, state_dim].

split_time_indices(time_points: tf.Tensor)tf.Tensor[source]

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.

Parameters

time_points – A tensor with shape batch_shape + [num_time_points].

Returns

A tensor of indices in range 0 - num_change_points, with shape batch_shape + [num_time_points].

split_input(input_tensor: tf.Tensor, indices: tf.Tensor)List[tf.Tensor][source]

Partitions input_tensor into regions determined 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.

Parameters
  • input_tensor – An arbitrary input tensor, with shape batch_shape + [N].

  • indices – The index for each input of the input tensor, with shape batch_shape + [N].

Returns

A list of tensors each with shape batch_shape + [Nₖ], where \((Σₖ Nₖ = N)\).

steady_state_covariances(time_points: tf.Tensor)tf.Tensor[source]

For each time point, return the steady state covariance of the kernel active for that time point.

Parameters

time_points – A tensor with shape batch_shape + [num_time_points].

Returns

The steady state covariance at each time point, with shape batch_shape + [num_time_points, state_dim, state_dim].

state_transitions(transition_times: tf.Tensor, time_deltas: tf.Tensor)tf.Tensor[source]

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.

Parameters
  • transition_times – Time points at which to produce matrices, with shape batch_shape + [num_transitions].

  • time_deltas – Time gaps for which to produce matrices, with shape batch_shape + [num_transitions].

Returns

A tensor with shape batch_shape + [num_transitions, state_dim, state_dim].

transition_statistics(transition_times: tf.Tensor, time_deltas: tf.Tensor)Tuple[tf.Tensor, tf.Tensor][source]

Return state_transitions() and process_covariances() together to save having to compute them twice.

Parameters
  • 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].

Returns

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(time_points: tf.Tensor)tf.Tensor[source]

For each time point, return the non-stationary feedback matrix \(F(t)\) of the kernel active for that time point.

Parameters

time_points – A tensor with shape batch_shape + [num_time_points].

Returns

The feedback matrix at each time point, with shape batch_shape + [num_time_points, state_dim, state_dim].

state_offsets(transition_times: tf.Tensor, time_deltas: tf.Tensor)tf.Tensor[source]

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].

Parameters

time_deltas – A tensor of time gaps for which to produce matrices, with shape batch_shape + [num_transitions].

Returns

A tensor with shape batch_shape + [num_transitions, state_dim]

state_means(time_points: tf.Tensor)tf.Tensor[source]

For each time point, return the state mean of the kernel active for that time point.

Parameters

time_points – A tensor with shape batch_shape + [num_time_points].

Returns

The state mean at each time point batch_shape + [num_time_points, state_dim].