base
====

.. py:module:: smolgp.kernels.base

.. autoapi-nested-parse::

   These kernels are compatible with :class:`smolgp.solvers.StateSpaceSolver`,
   which uses Bayesian filtering and smoothing algorithms to perform scalable GP
   inference. (see :mod:`smolgp.solvers` for more technical details).
   On GPU, a performance boost may be observed for large datasets by using the
   :class:`smolgp.solvers.parallel.ParallelStateSpaceSolver` class.

   Like the quasisep kernels, these methods are experimental, so you may find
   the documentation patchy in places. You are encouraged to `open issues or
   pull requests <https://github.com/smolgp-dev/smolgp/issues>`_ as you find gaps.



Classes
-------

.. autoapisummary::

   smolgp.kernels.base.StateSpaceModel
   smolgp.kernels.base.Sum
   smolgp.kernels.base.Product
   smolgp.kernels.base.Wrapper
   smolgp.kernels.base.Scale
   smolgp.kernels.base.Constant
   smolgp.kernels.base.SHO
   smolgp.kernels.base.Exp
   smolgp.kernels.base.Matern32
   smolgp.kernels.base.Matern52
   smolgp.kernels.base.Cosine
   smolgp.kernels.base.ExpSineSquared
   smolgp.kernels.base.Matern


Functions
---------

.. autoapisummary::

   smolgp.kernels.base.extract_leaf_kernels


Module Contents
---------------

.. py:function:: extract_leaf_kernels(kernel, all=False)

   Recursively extract leaf kernels from a sum or product of kernels

   If all==True, extract from both Sum and Product nodes
       (useful for returning all kernel elements).
   Default is False, which only extracts from Sum nodes.
       (as used in decomposing multi-component models, only valid for sums)


.. py:class:: StateSpaceModel

   Bases: :py:obj:`tinygp.kernels.base.Kernel`


   The base class for an instantaneous linear Gaussian state space model.

   .. attribute:: name

      Unique identifier used in multi-component models to select
      individual components from a sum or product kernel.

      :type: str

   .. attribute:: dimension

      Dimensionality :math:`d` of the state space model.

      :type: int

   A state space model is defined by the following components:

   1. :meth:`design_matrix` — The feedback matrix :math:`F`
   2. :meth:`stationary_covariance` — The stationary covariance :math:`\mathbf{P}_\infty`
   3. :meth:`observation_matrix` — The observation matrix :math:`H`
   4. :meth:`noise` — The spectral density :math:`Q_c` of the driving white noise
   5. :meth:`noise_effect_matrix` — The noise effect matrix :math:`L`
   6. :meth:`transition_matrix` — The transition matrix :math:`A_k`
      (optional; default uses :func:`jax.scipy.linalg.expm`)
   7. :meth:`process_noise` — The process noise :math:`Q_k`
      (optional; default uses :math:`\mathbf{P}_\infty - A_k \mathbf{P}_\infty A_k^\top`
      or the Van Loan matrix exponential)

   As a subclass of :class:`tinygp.kernels.Kernel`, this class supports
   addition and multiplication with other kernels via :class:`Sum` and
   :class:`Product`, as well as direct kernel evaluation.


   .. py:attribute:: name
      :type:  str


   .. py:method:: coord_to_sortable(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      A helper function used to convert coordinates to sortable 1-D values

      By default, this is the identity, but in cases where ``X`` is structured
      (e.g. multivariate inputs), this can be used to appropriately unwrap
      that structure.



   .. py:property:: dimension
      :type: int


      The dimension of the state space model, d


   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray
      :abstractmethod:


      The design (also called the feedback) matrix for the process, :math:`F`



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray
      :abstractmethod:


      The stationary covariance of the process, :math:`\mathbf{P}_\infty`



   .. py:method:: observation_model(X: tinygp.helpers.JAXArray, component: str | None = None) -> tinygp.helpers.JAXArray

      The observation model for the process, :math:`H`



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray
      :abstractmethod:


      The observation matrix for the process, :math:`H`



   .. py:method:: noise() -> tinygp.helpers.JAXArray
      :abstractmethod:


      The spectral density of the white noise process, :math:`Q_c`



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray
      :abstractmethod:


      The noise effect matrix, :math:`L`



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix :math:`A_k` between two states at coordinates X1 and X2.

      Default behavior uses jax.scipy.linalg.expm(self.design_matrix() * (X2 - X1)),
      which is appropriate for stationary kernels defined by a linear Gaussian SSM.

      Overload this method if you have a more general model or simply wish to
      define the transition matrix analytically.



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray, use_van_loan=False) -> tinygp.helpers.JAXArray

      The process noise matrix :math:`Q_k`

      Default behavior computes :math:`Q_k = \mathbf{P}_\infty - A_k \mathbf{P}_\infty A_k^T`
      (see `Eq. 7 in Solin & Särkka (2014) <https://users.aalto.fi/~ssarkka/pub/solin_mlsp_2014.pdf>`_).
      Pass ``use_van_loan=True`` to instead compute :math:`Q_k` via the
      `Van Loan (1978) <https://ecommons.cornell.edu/items/cba38b2e-6ad4-45e6-8109-0a019fe5114c>`_
      matrix exponential method using :math:`F`, :math:`L`, and :math:`Q_c`.

      Overload this method if you have a more general model or wish to
      define the process noise analytically.



   .. py:method:: reset_matrix(instid: int = 0) -> tinygp.helpers.JAXArray

      The reset matrix for an instantaneous state
      space model is trivially the identity matrix.



   .. py:method:: __add__(other: tinygp.kernels.base.Kernel | tinygp.helpers.JAXArray) -> tinygp.kernels.base.Kernel


   .. py:method:: __radd__(other: Any) -> tinygp.kernels.base.Kernel


   .. py:method:: __mul__(other: tinygp.kernels.base.Kernel | tinygp.helpers.JAXArray) -> tinygp.kernels.base.Kernel


   .. py:method:: __rmul__(other: Any) -> tinygp.kernels.base.Kernel


   .. py:method:: evaluate(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The kernel evaluated via the state space representation.

      See `Eq. 4 in Hartikainen & Särkkä (2010) <https://users.aalto.fi/~ssarkka/pub/gp-ts-kfrts.pdf>`_.



   .. py:method:: evaluate_diag(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      For state space kernels, the variance is simple to compute



   .. py:method:: psd(omega: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The power spectral density (PSD) of the kernel.

      See `Eq. 8 in Solin & Särkka (2014) <https://users.aalto.fi/~ssarkka/pub/solin_mlsp_2014.pdf>`_.



.. py:class:: Sum(kernel1, kernel2)

   Bases: :py:obj:`StateSpaceModel`


   The sum of two :class:`StateSpaceModel` kernels.

   The joint state dimension is :math:`d = d_1 + d_2`, and all matrices are
   assembled as block-diagonal combinations of the two component kernels.


   .. py:attribute:: kernel1
      :type:  StateSpaceModel


   .. py:attribute:: kernel2
      :type:  StateSpaceModel


   .. py:attribute:: name


   .. py:property:: dimension
      :type: int


      The dimension of the summed state space model


   .. py:method:: coord_to_sortable(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      We assume that both kernels use the same coordinates



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      :math:`F = \mathrm{BlockDiag}(F_1,\, F_2)`



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      :math:`L = \mathrm{BlockDiag}(L_1,\, L_2)`



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      :math:`\mathbf{P}_\infty = \mathrm{BlockDiag}(\mathbf{P}_{\infty,1},\, \mathbf{P}_{\infty,2})`



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`A_k = \mathrm{BlockDiag}(A_{k,1},\, A_{k,2})`



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`Q_k = \mathrm{BlockDiag}(Q_{k,1},\, Q_{k,2})`



   .. py:method:: observation_model(X: tinygp.helpers.JAXArray, component=None) -> tinygp.helpers.JAXArray

      :math:`H = [H_1 \;\; H_2]`, with optional component masking.



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`H = [H_1 \;\; H_2]`



   .. py:method:: reset_matrix(instid: int = 0) -> tinygp.helpers.JAXArray

      :math:`\mathrm{RESET} = \mathrm{BlockDiag}(\mathrm{RESET}_1,\, \mathrm{RESET}_2)`



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      :math:`Q_c = \mathrm{BlockDiag}(Q_{c,1},\, Q_{c,2})`



.. py:class:: Product(kernel1, kernel2)

   Bases: :py:obj:`StateSpaceModel`


   The product of two :class:`StateSpaceModel` kernels.

   The joint state dimension is :math:`d = d_1 \cdot d_2`, and all matrices are
   assembled using Kronecker products of the two component kernels.


   .. py:attribute:: kernel1
      :type:  StateSpaceModel


   .. py:attribute:: kernel2
      :type:  StateSpaceModel


   .. py:attribute:: name


   .. py:property:: dimension
      :type: int


      The dimension of the product state space model


   .. py:method:: coord_to_sortable(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      We assume that both kernels use the same coordinates



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      :math:`F = F_1 \otimes I + I \otimes F_2`



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      :math:`L` for products is not uniquely defined, only the combination
      :math:`L Q_c L^T` is. A convenient choice then for :math:`L` is the
      identity matrix, which we return here. Then, :math:`Q_c` is chosen so that
      :math:`L Q_c L^T` gives the correct process noise.



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      :math:`\mathbf{P}_\infty = \mathbf{P}_{\infty,1} \otimes \mathbf{P}_{\infty,2}`



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`A_k = A_{k,1} \otimes A_{k,2}`



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`Q_k` for a product is best determined via the identity
      :math:`Q_k = \mathbf{P}_\infty - A_k \mathbf{P}_\infty A_k^T`.



   .. py:method:: observation_model(X: tinygp.helpers.JAXArray, component=None) -> tinygp.helpers.JAXArray

      :math:`H = H_1 \otimes H_2`, with optional component masking.



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      :math:`H = H_1 \otimes H_2`



   .. py:method:: reset_matrix(instid: int = 0) -> tinygp.helpers.JAXArray

      :math:`\mathrm{RESET} = \mathrm{RESET}_1 \otimes \mathrm{RESET}_2`



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      :math:`Q_c` for products is not uniquely defined.

      Returns :math:`Q_c = L_1 Q_{c,1} L_1^T \otimes \mathbf{P}_{\infty,2} + \mathbf{P}_{\infty,1} \otimes L_2 Q_{c,2} L_2^T`,
      with :math:`L = I`, so that :math:`L Q_c L^T` yields the correct process noise.



.. py:class:: Wrapper

   Bases: :py:obj:`StateSpaceModel`


   A base class for wrapping kernels with some custom implementations


   .. py:attribute:: kernel
      :type:  StateSpaceModel


   .. py:property:: dimension
      :type: int


      The dimension of the state space model, d


   .. py:method:: coord_to_sortable(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      A helper function used to convert coordinates to sortable 1-D values

      By default, this is the identity, but in cases where ``X`` is structured
      (e.g. multivariate inputs), this can be used to appropriately unwrap
      that structure.



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the process, :math:`F`



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix, :math:`L`



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The spectral density of the white noise process, :math:`Q_c`



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the process, :math:`\mathbf{P}_\infty`



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation matrix for the process, :math:`H`



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix :math:`A_k` between two states at coordinates X1 and X2.

      Default behavior uses jax.scipy.linalg.expm(self.design_matrix() * (X2 - X1)),
      which is appropriate for stationary kernels defined by a linear Gaussian SSM.

      Overload this method if you have a more general model or simply wish to
      define the transition matrix analytically.



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise matrix :math:`Q_k`

      Default behavior computes :math:`Q_k = \mathbf{P}_\infty - A_k \mathbf{P}_\infty A_k^T`
      (see `Eq. 7 in Solin & Särkka (2014) <https://users.aalto.fi/~ssarkka/pub/solin_mlsp_2014.pdf>`_).
      Pass ``use_van_loan=True`` to instead compute :math:`Q_k` via the
      `Van Loan (1978) <https://ecommons.cornell.edu/items/cba38b2e-6ad4-45e6-8109-0a019fe5114c>`_
      matrix exponential method using :math:`F`, :math:`L`, and :math:`Q_c`.

      Overload this method if you have a more general model or wish to
      define the process noise analytically.



   .. py:method:: reset_matrix(instid=0)

      The reset matrix for an instantaneous state
      space model is trivially the identity matrix.



.. py:class:: Scale

   Bases: :py:obj:`Wrapper`


   The product of a scalar and a state space kernel.


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the process, :math:`\mathbf{P}_\infty`



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The spectral density of the white noise process, :math:`Q_c`



.. py:class:: Constant(sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'Constant', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A constant kernel

   .. math::

       k(\mathbf{x}_i,\,\mathbf{x}_j) = \sigma^2

   where :math:`\sigma` is a parameter.

   :param sigma: The parameter :math:`\sigma` in the above equation.


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'Constant'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for a Constant process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of a Constant process, Pinf



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for a Constant process



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for a Constant process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for a Constant process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for a Constant process



   .. py:method:: process_noise(X1, X2, use_van_loan=False)

      The process noise Q_k for a Constant process



.. py:class:: SHO(omega: tinygp.helpers.JAXArray | float, quality: tinygp.helpers.JAXArray | float, sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'SHO', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   The damped, driven stochastic harmonic oscillator kernel

   This form of the kernel was introduced by `Foreman-Mackey et al. (2017)
   <https://arxiv.org/abs/1703.09710>`_, and it takes the form:

   .. math::

       k(\Delta) = \sigma^2\,\exp\left(-\frac{\omega_0\,\Delta}{2\,Q}\right)
       \left\{\begin{array}{ll}
           1 + \omega_0\,\Delta & \mbox{for } Q = 1/2 \\
           \cosh(\eta\,\omega_0\,\Delta) + \frac{1}{2\eta Q} \sinh(\eta\,\omega_0\,\Delta)
               & \mbox{for } Q < 1/2 \\
           \frac{1}{2\eta Q}\cos(\eta\,\omega_0\,\Delta) + \sin(\eta\,\omega_0\,\Delta)
               & \mbox{for } Q > 1/2
       \end{array}\right.

   for :math:`\Delta = |x_i - x_j|`, :math:`\eta = \sqrt{|1 - 1/(4Q^2)|}`.

   :param omega: The parameter :math:`\omega_0`.
   :param quality: The parameter :math:`Q`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of
                 1. Specifying the explicit value here provides a slight performance
                 boost compared to independently multiplying the kernel with a
                 prefactor.
   :type sigma: optional


   .. py:attribute:: omega
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: quality
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: eta
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'SHO'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the SHO process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the SHO process, Pinf



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the SHO process



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the SHO process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the SHO process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for the SHO process



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise Q_k for the SHO process



.. py:class:: Exp(scale: tinygp.helpers.JAXArray | float, sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'Exp', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A state space implementation of :class:`tinygp.kernels.quasisep.Exp`

   This kernel takes the form:

   .. math::

       k(\Delta)=\sigma^2\,\exp\left(-\frac{\Delta}{\ell}\right)

   for :math:`\Delta = |x_i - x_j|`. Also known as the "Ornstein-Uhlenbeck" kernel,
   and is also equivalent to a Matérn-1/2 kernel.

   :param scale: The parameter :math:`\ell`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.
   :type sigma: optional


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: lam
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'Exp'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the Exp process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the Exp process, Pinf



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the Exp process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the Exp process



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the Exp process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for the Exp process



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise Q_k for the Exp process



.. py:class:: Matern32(scale: tinygp.helpers.JAXArray | float, sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'Matern32', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A state space implementation of :class:`tinygp.kernels.quasisep.Matern32`

   This kernel takes the form:

   .. math::

       k(\Delta)=\sigma^2\,\left(1+f\,\Delta\right)\,\exp(-f\,\Delta)

   for :math:`\Delta = |x_i - x_j|` and :math:`f = \sqrt{3} / \ell`.

   :param scale: The parameter :math:`\ell`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.
   :type sigma: optional


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: lam
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'Matern32'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the Matern-3/2 process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the Matern-3/2 process, Pinf



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the Matern-3/2 process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the Matern-3/2 process



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the Matern-3/2 process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for the Matern-3/2 process



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise Q_k for the Matern-3/2 process



.. py:class:: Matern52(scale: tinygp.helpers.JAXArray | float, sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'Matern52', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A state space implementation of :class:`tinygp.kernels.quasisep.Matern52`

   This kernel takes the form:

   .. math::

       k(\Delta)=\sigma^2\,\left(1+f\,\Delta + \frac{f^2\,\Delta^2}{3}\right)
           \,\exp(-f\,\Delta)

   for :math:`\Delta = |x_i - x_j|` and :math:`f = \sqrt{5} / \ell`.

   :param scale: The parameter :math:`\ell`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.
   :type sigma: optional


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: lam
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'Matern52'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the Matern-5/2 process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the Matern-5/2 process, Pinf



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the Matern-5/2 process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the Matern-5/2 process



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the Matern-5/2 process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for the Matern-5/2 process



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise Q_k for the Matern-5/2 process



.. py:class:: Cosine(scale, sigma=jnp.ones(()), name='Cosine', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A state space implementation of :class:`tinygp.kernels.quasisep.Cosine`

   This kernel takes the form:

   .. math::

       k(\Delta)=\sigma^2\,\cos(-2\,\pi\,\Delta/\ell)

   for :math:`\Delta = |x_i - x_j|`.

   :param scale: The parameter :math:`\ell`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.
   :type sigma: optional


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: omega
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name
      :value: 'Cosine'



   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the Cosine process, F



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the Cosine process, Pinf



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the Cosine process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the Cosine process



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the Cosine process



   .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The transition matrix A_k for the Cosine process



   .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The process noise Q_k for the Cosine process



.. py:class:: ExpSineSquared(period: tinygp.helpers.JAXArray | float, gamma: tinygp.helpers.JAXArray | float = jnp.ones(()), sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'ExpSineSquared', order: int | None = None, **kwargs)

   Bases: :py:obj:`Wrapper`


   The exponential sine squared or "periodic" kernel

   .. math::

       k(\mathbf{x}_i,\,\mathbf{x}_j) = \sigma^2 \exp(-\Gamma\,\sin^2 \pi r)

   where, by default,

   .. math::

       r = ||(\mathbf{x}_i - \mathbf{x}_j) / P||_1

   In the state space representation, this kernel is approximated using
   a finite number of basis functions. The method was introduced by
   `Solin & Särkkä (2014) <https://proceedings.mlr.press/v33/solin14.html>`_.
   See their Figure 2 for the number of basis functions required to reach desired accuracy.
   Default behavior will automatically select the number of basis functions
   based on the length scale :math:`\ell`.

   :param period: The parameter :math:`P`.
   :param gamma: The parameter :math:`\Gamma`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.


   .. py:attribute:: gamma
      :type:  tinygp.helpers.JAXArray | float | None
      :value: None



   .. py:attribute:: period
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: omega
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: order
      :type:  int | None


   .. py:attribute:: kernel
      :type:  StateSpaceModel


   .. py:attribute:: name
      :value: 'ExpSineSquared'



   .. py:method:: error_bound()

      An upper bound on the error in the covariance
      from the Taylor series approximation.

      See Sec 3.4 of Solin & Särkkä (2014).



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the process, :math:`\mathbf{P}_\infty`



   .. py:class:: PeriodicTerm(order, omega, scale, **kwargs)

      Bases: :py:obj:`StateSpaceModel`


      A single term in the state space representation of the
      exponential sine squared or "periodic" kernel

      See Solin & Särkkä (2014) for details.


      .. py:attribute:: order
         :type:  int


      .. py:attribute:: omega
         :type:  tinygp.helpers.JAXArray | float


      .. py:attribute:: scale
         :type:  tinygp.helpers.JAXArray | float


      .. py:attribute:: name


      .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

         The design (also called the feedback) matrix for the PeriodicTerm, :math:`F`



      .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

         The stationary covariance of the PeriodicTerm process, :math:`\mathbf{P}_\infty`



      .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

         The observation matrix for the PeriodicTerm, :math:`H`



      .. py:method:: noise() -> tinygp.helpers.JAXArray

         The spectral density of the white noise for the PeriodicTerm, :math:`Q_c`



      .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

         The noise effect matrix :math:`L` for the PeriodicTerm



      .. py:method:: Ij(j, x, terms=50) -> tinygp.helpers.JAXArray

         The modified Bessel function of the first kind, order j, at x.
         Approximated via a truncated Taylor series expansion.



      .. py:method:: transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

         The transition matrix A_k for the PeriodicTerm



      .. py:method:: process_noise(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

         The process noise Q_k for the PeriodicTerm




.. py:class:: Matern(nu: tinygp.helpers.JAXArray | float, scale: tinygp.helpers.JAXArray | float, sigma: tinygp.helpers.JAXArray | float = jnp.ones(()), name: str = 'Matern', **kwargs)

   Bases: :py:obj:`StateSpaceModel`


   A state space implementation of the generic half-integer Matérn kernel
   with smoothness parameter :math:`\nu = p + 1/2` for integer :math:`p \geq 0`,
   length scale :math:`\ell`, and amplitude :math:`\sigma`.

   The model is dimension :math:`d = \nu + 1/2` and has the form
   (see Eq. 12.34-35 of Särkkä and Solin 2019):

   .. math::

       F = \begin{pmatrix}
               0      & 1 & 0 & & \\
               \vdots & 0 & 1 & & \\
                      &   & \ddots & \ddots & \\
        -a_1\lambda^d & -a_2\lambda^{d-1} & \cdots & -a_d\lambda
           \end{pmatrix}, L = \begin{pmatrix}
               0 \\
               \vdots \\
               0 \\
               1
           \end{pmatrix},
   where :math:`\lambda = \sqrt{2\nu}/\ell` and the coefficients
   :math:`a_i = \binom{d}{i-1}` are the binomial coefficients.
   The spectral noise density is given by:

   .. math::

       Q_c = \sigma^2 \frac{[(d-1)!]^2}{(2d-2)!} (2\lambda)^{2d-1}.

   :param nu: The smoothness parameter :math:`\nu` (must be half-integer).
   :param scale: The parameter :math:`\ell`.
   :param sigma: The parameter :math:`\sigma`. Defaults to a value of 1.
   :type sigma: optional


   .. py:attribute:: nu
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: scale
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: sigma
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: lam
      :type:  tinygp.helpers.JAXArray | float


   .. py:attribute:: name


   .. py:property:: dimension
      :type: int


      The dimension of the state space for the Matérn process


   .. py:method:: design_matrix() -> tinygp.helpers.JAXArray

      The design (also called the feedback) matrix for the Matern process, F



   .. py:method:: observation_matrix(X: tinygp.helpers.JAXArray) -> tinygp.helpers.JAXArray

      The observation model H for the Matern process



   .. py:method:: noise_effect_matrix() -> tinygp.helpers.JAXArray

      The noise effect matrix L for the Matern process



   .. py:method:: noise() -> tinygp.helpers.JAXArray

      The scalar Qc for the Matern process



   .. py:method:: stationary_covariance() -> tinygp.helpers.JAXArray

      The stationary covariance of the Matérn process, :math:`\mathbf{P}_\infty`



