markovflow.kernels.matern

Module containing the Matern family of kernels.

Module Contents

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

Bases: markovflow.kernels.sde_kernel.StationaryKernel

Represents the Matern1/2 kernel. This kernel has the formula:

\[C(x, x') = σ² exp(-|x - x'| / ℓ)\]

…where lengthscale \(ℓ\) and signal variance \(σ²\) are kernel parameters.

This defines an SDE where:

\[\begin{split}&F = - 1/ℓ\\ &L = 1\end{split}\]

…so that \(Aₖ = exp(-Δtₖ/ℓ)\).

Parameters
  • lengthscale – A value for the lengthscale parameter.

  • variance – A value for the variance parameter.

  • 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 kernel, which is always one.

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

Return the state transition matrices kernel.

The state dimension is one, so the matrix exponential reduces to a standard one:

\[Aₖ = exp(-Δtₖ/ℓ)\]

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 \(F = - 1 / ℓ\).

Returns

A tensor with shape [state_dim, state_dim].

property steady_state_covariancetf.Tensor[source]

Return the steady state covariance \(P∞\). For this kernel, this is the variance hyperparameter.

Returns

A tensor with shape [state_dim, state_dim].

property lengthscalegpflow.Parameter[source]

Return the lengthscale parameter. This is a GPflow Parameter.

property variancegpflow.Parameter[source]

Return the variance parameter. This is a GPflow Parameter.

class OrnsteinUhlenbeck(decay: float, diffusion: float, output_dim: int = 1, jitter: float = 0.0)[source]

Bases: markovflow.kernels.sde_kernel.StationaryKernel

Represents the Ornstein–Uhlenbeck kernel. This is an alternative parameterization of the Matern1/2 kernel. This kernel has the formula:

\[C(x, x') = q/2λ exp(-λ|x - x'|)\]

…where decay \(λ\) and diffusion coefficient \(q\) are kernel parameters.

This defines an SDE where:

\[\begin{split}&F = - λ\\ &L = q\end{split}\]

…so that \(Aₖ = exp(-λ Δtₖ)\).

Parameters
  • decay – A value for the decay parameter.

  • diffusion – A value for the diffusion parameter.

  • 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 kernel, which is always one.

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

Return the state transition matrices kernel.

The state dimension is one, so the matrix exponential reduces to a standard one:

\[Aₖ = exp(-λ Δtₖ)\]

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 \(F = -λ\).

Returns

A tensor with shape [state_dim, state_dim].

property steady_state_covariancetf.Tensor[source]

Return the steady state covariance \(P∞\). For this kernel, this is q/2λ.

Returns

A tensor with shape [state_dim, state_dim].

property decaygpflow.Parameter[source]

Return the decay parameter. This is a GPflow Parameter.

property diffusiongpflow.Parameter[source]

Return the diffusion parameter. This is a GPflow Parameter.

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

Bases: markovflow.kernels.sde_kernel.StationaryKernel

Represents the Matern3/2 kernel. This kernel has the formula:

\[C(x, x') = σ² (1 + λ|x - x'|) exp(λ|x - x'|)\]

…where \(λ = √3 / ℓ\), and lengthscale \(ℓ\) and signal variance \(σ²\) are kernel parameters.

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

\[\begin{split}F = &[[0, 1]\\ &[[-λ², -2λ]]\end{split}\]

Covariance for the initial state is:

\[\begin{split}P∞ = [&[1, 0],\\ &[0, λ²]] * \verb|variance|\end{split}\]

…where variance is a kernel parameter.

Since the characteristic equation for the feedback matrix \(F\) for this kernel is \((λI + F)² = 0\), the state transition matrix is:

\[\begin{split}Aₖ &= expm(FΔtₖ)\\ &= exp(-λΔtₖ) expm((λI + F)Δtₖ)\\ &= exp(-λΔtₖ) (I + (λI + F)Δtₖ)\end{split}\]

…where \(expm\) is the matrix exponential operator. Note that all higher order terms of \(expm((λI + F)Δtₖ)\) disappear.

Parameters
  • lengthscale – A value for the lengthscale parameter.

  • variance – A value for the variance parameter.

  • 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 _lambdatf.Tensor[source]

λ the scalar used elsewhere in the docstrings

property state_dimint[source]

Return the state dimension of the kernel, which is always two.

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

Return the state transition matrices for the kernel.

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 &1]\\ &[-λ² &-2λ]\end{split}\]
Returns

A tensor with shape [state_dim, state_dim].

property steady_state_covariancetf.Tensor[source]

Return the steady state covariance \(P∞\). This is given by:

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

A tensor with shape [state_dim, state_dim].

property lengthscalegpflow.Parameter[source]

Return the lengthscale parameter. This is a GPflow Parameter.

property variancegpflow.Parameter[source]

Return the variance parameter. This is a GPflow Parameter.

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

Bases: markovflow.kernels.sde_kernel.StationaryKernel

Represents the Matern5/2 kernel. This kernel has the formula:

\[C(x, x') = σ² (1 + λ|x - x'| + λ²|x - x'|²/3) exp(λ|x - x'|)\]

…where \(λ = √5 / ℓ\), and lengthscale \(ℓ\) and signal variance \(σ²\) are kernel parameters.

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

F = [  0,    1,   0]
    [  0,    0,   1]
    [-λ³, -3λ², -3λ]

Covariance for the initial state is:

P∞ = σ² [    1,    0, -λ²/3]
        [    0, λ²/3,     0]
        [-λ²/3,    0,    λ⁴]

Since the characteristic equation for the feedback matrix \(F\) for this kernel is \((λI + F)³ = 0\), the state transition matrix is:

\[\begin{split}Aₖ &= expm(FΔtₖ)\\ &= exp(-λΔtₖ) expm((λI + F)Δtₖ)\\ &= exp(-λΔtₖ) (I + (λI + F)Δtₖ + (λI + F)²Δtₖ²/2)\end{split}\]

…where \(expm\) is the matrix exponential operator. Note that all higher order terms disappear.

Parameters
  • lengthscale – A value for the lengthscale parameter.

  • variance – A value for the variance parameter.

  • 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 _lambdatf.Tensor[source]

λ the scalar used elsewhere in the docstrings

property state_dimint[source]

Return the state dimension of the kernel, which is always three.

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

Return the state transition matrices for the kernel.

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:

F = [[  0,    1,   0]
     [  0,    0,   1]
     [-λ³, -3λ², -3λ]]
Returns

A tensor with shape [state_dim, state_dim].

property steady_state_covariancetf.Tensor[source]

Return the steady state covariance \(P∞\). This is given by:

P∞ = σ² [    1,    0, -λ²/3]
        [    0, λ²/3,     0]
        [-λ²/3,    0,    λ⁴]
Returns

A tensor with shape [state_dim, state_dim].

property lengthscalegpflow.Parameter[source]

Return the lengthscale parameter. This is a GPflow Parameter.

property variancegpflow.Parameter[source]

Return the variance parameter. This is a GPflow Parameter.

_check_lengthscale_and_variance(lengthscale: float, variance: float)None[source]

Verify that the lengthscale and variance are positive