markovflow.kernels.periodic

Module containing a periodic kernel.

Module Contents

class HarmonicOscillator(variance: float, period: float, output_dim: int = 1, jitter: float = 0.0)[source]

Bases: markovflow.kernels.sde_kernel.StationaryKernel

Represents a periodic kernel. The definition is in the paper “Explicit Link Between Periodic Covariance Functions and State Space Models”.

This kernel has the formula:

\[C(x, x') = σ² cos(2π/p * (x-x'))\]

…where:

  • \(σ²\) is a kernel parameter, representing the constant variance this kernel introduces

  • \(p\) is the period of the oscillator in radius

The transition matrix \(F\) in the SDE form for this kernel is:

\[\begin{split}F = [&[0, -λ],\\ &[λ, 0]].\end{split}\]

…where \(λ = 2π / period\).

Covariance for the steady state is:

\[\begin{split}P∞ = [&[σ², 0],\\ &[0, σ²]].\end{split}\]

The state transition matrix is:

\[\begin{split}Aₖ = [&[cos(Δtₖλ), -sin(Δtₖλ)],\\ &[sin(Δtₖλ), cos(Δtₖλ)]]\end{split}\]

The process covariance is:

\[\begin{split}Qₖ = [&[0, 0],\\ &[0, 0]].\end{split}\]
Parameters
  • variance – Initial variance for the kernel. Must be a positive float.

  • period – The period of the Harmonic oscillator, in radius. Must be a positive float.

  • output_dim – The output dimension of the kernel.

  • jitter – A small non-negative number used to make sure that matrix inversion is numerically stable.

property _lambdatf.Tensor[source]

λ the scalar used elsewhere in the docstrings

property state_dimint[source]

Return the state dimension of the generated StateSpaceModel.

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

Return the state transition matrices of the kernel.

The state transition matrix at time step \(k\) is:

\[\begin{split}Aₖ = [&[cos(Δtₖλ), -sin(Δtₖλ)],\\ &[sin(Δtₖλ), cos(Δtₖλ)]].\end{split}\]

…where \(λ = 2π / period\).

Because this is a stationary kernel, transition_times is ignored.

Parameters
  • transition_times – A tensor of times at which to produce matrices, with shape batch_shape + [num_transitions]. Ignored.

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

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

Return the state transition matrices of the kernel.

The process covariance for time step k is:

\[\begin{split}Qₖ = [&[0, 0],\\ &[0, 0]].\end{split}\]

Because this is a stationary kernel, transition_times is ignored.

Parameters
  • transition_times – A tensor of times at which to produce matrices, with shape batch_shape + [num_transitions]. Ignored.

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

property feedback_matrixtf.Tensor[source]

Return the feedback matrix \(F\). This is where:

\[dx(t)/dt = F x(t) + L w(t)\]

For this kernel, note that:

\[\begin{split}F = [&[0, -λ],\\ &[λ, 0]].\end{split}\]
Returns

A tensor with shape [state_dim, state_dim].

property steady_state_covariancetf.Tensor[source]

Return the initial covariance of the generated StateSpaceModel.

The steady state covariance \(P∞\) is given by:

\[\begin{split}P∞ = [&[σ², 0],\\ &[0, σ²]].\end{split}\]
Returns

A tensor with shape [state_dim, state_dim].

property variancegpflow.Parameter[source]

Return the variance parameter. This is a GPflow Parameter.

property periodgpflow.Parameter[source]

Return the period parameter. This is a GPflow Parameter.