superstats.transition.stochastic.kernel.periodic#

Periodic covariance kernels.

Functions

build_abs_dist_mat(num_steps)

Absolute pairwise distances for num_steps evenly spaced points on [0, 1].

get_periodic_kernel(num_steps, length_scale, ...)

Batched periodic kernel construction.

Classes

PeriodicKernel([name])

Periodic kernel.

class superstats.transition.stochastic.kernel.periodic.PeriodicKernel(name=None)[source]#

Bases: Kernel

Periodic kernel. Requires hyperparameters length_scale, period, amplitude.

Models functions that repeat themselves exactly. period sets the distance between repetitions; length_scale controls smoothness of the repeated shape, same interpretation as in RBFKernel.

Parameters:
namestr, optional

Prefix for this kernel’s hyperparameter names. Leave unset for a single periodic kernel, or when combining with a kernel of a different type. Required when combining two periodic kernels.

Parameters:

name (str | None)

build(num_steps, **hyperparams)[source]#

Construct the (batch_size, num_steps, num_steps) kernel matrix.

Parameters:
num_stepsint
**hyperparamsnp.ndarray

Must contain every name in self.hyperparam_names, each of shape (batch_size,). Extra keys (from sibling kernels in a composite) are ignored.

Returns:
kernel_matnp.ndarray of shape (batch_size, num_steps, num_steps)
Parameters:
Return type:

ndarray

superstats.transition.stochastic.kernel.periodic.build_abs_dist_mat(num_steps)[source]#

Absolute pairwise distances for num_steps evenly spaced points on [0, 1].

Parameters:
num_stepsint

Number of points in the 1D grid.

Returns:
abs_distnp.ndarray of shape (num_steps, num_steps)

Absolute distance between point i and point j at [i, j].

Parameters:

num_steps (int)

Return type:

ndarray

superstats.transition.stochastic.kernel.periodic.get_periodic_kernel(num_steps, length_scale, period, amplitude)[source]#

Batched periodic kernel construction.

k(x, x_prime) = amplitude^2 * exp(-2 * sin^2(pi * |x - x_prime| / period) / length_scale^2)

Parameters:
num_stepsint

Number of points in the 1D grid.

length_scalenp.ndarray of shape (batch_size,)

Smoothness of the repeated shape; smaller values mean a more wiggly repeating pattern, larger values a smoother one.

periodnp.ndarray of shape (batch_size,)

Distance between repetitions, on the [0, 1] grid.

amplitudenp.ndarray of shape (batch_size,)

Kernel variance / overall scale per trajectory.

Returns:
kernel_matnp.ndarray of shape (batch_size, num_steps, num_steps)
Parameters:
Return type:

ndarray