CARMA#

class tinygp.kernels.quasisep.CARMA(alpha: Any, beta: Any)[source]#

Bases: Quasisep

A continuous-time autoregressive moving average (CARMA) process kernel

This process has the power spectrum density (PSD)

\[P(\omega) = \sigma^2\,\frac{|\sum_{q} \beta_q\,(i\,\omega)^q|^2}{|\sum_{p} \alpha_p\,(i\,\omega)^p|^2}\]

defined following Equation 1 in Kelly et al. (2014), where \(\alpha_p\) and \(\beta_0\) are set to 1. In this implementation, we absorb \(\sigma\) into the definition of \(\beta\) parameters. That is \(\beta_{new}\) = \(\beta * \sigma\).

Note

To construct a stationary CARMA kernel/process, the roots of the characteristic polynomials for Equation 1 in Kelly et al. (2014) must have negative real parts. This condition can be met automatically by requiring positive input parameters when instantiating the kernel using the init() method for CARMA(1,0), CARMA(2,0), and CARMA(2,1) models or by requiring positive input parameters when instantiating the kernel using the from_quads() method.

Note

Implementation details

The logic behind this implementation is simple—finding the correct combination of real/complex exponential kernels that resembles the autocovariance function of the CARMA model. Note that the order also matters. This task is achieved using the acvf method. Then the rest is copied from the Exp and Celerite kernel.

Given the requirement of negative roots for stationarity, the from_quads method is implemented to facilitate consturcting stationary higher-order CARMA models beyond CARMA(2,1). The inputs for from_quads are the coefficients of the quadratic equations factorized out of the full characteristic polynomial. poly2quads is used to factorize a polynomial into a product of said quadractic equations, and quads2poly is used for the reverse process.

One last trick is the use of _real_mask, _complex_mask, and complex_select, which are arrays of 0s and 1s. They are implemented to avoid control flows. More specifically, some intermediate quantities are computed regardless, but are only used if there is a matching real or complex exponential kernel for the specific CARMA kernel.

Parameters:
  • alpha – The parameter \(\alpha\) in the definition above, exlcuding \(\alpha_p\). This should be an array of length p.

  • beta – The product of parameters \(\beta\) and parameter \(\sigma\) in the definition above. This should be an array of length q+1, where q+1 <= p.

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.

design_matrix() tinygp.helpers.JAXArray[source]#

The design matrix for the process

evaluate(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray#

The kernel evaluated via the quasiseparable representation

evaluate_diag(X: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray#

For quasiseparable kernels, the variance is simple to compute

classmethod from_quads(alpha_quads: tinygp.helpers.JAXArray, beta_quads: tinygp.helpers.JAXArray, beta_mult: tinygp.helpers.JAXArray) CARMA[source]#

Construct a CARMA kernel using the roots of its characteristic polynomials

The roots can be parameterized as the 0th and 1st order coefficients of a set of quadratic equations (2nd order coefficient equals 1). The product of those quadratic equations gives the characteristic polynomials of CARMA. The input of this method are said coefficients of the quadratic equations. See Equation 30 in Kelly et al. (2014). for more detail.

Parameters:
  • alpha_quads – Coefficients of the auto-regressive (AR) quadratic equations corresponding to the \(\alpha\) parameters. This should be an array of length p.

  • beta_quads – Coefficients of the moving-average (MA) quadratic equations corresponding to the \(\beta\) parameters. This should be an array of length q.

  • beta_mult – A multiplier of the MA coefficients, equivalent to \(\beta_q\)—the last entry of the \(\beta\) parameters input to the init() method.

observation_model(X: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray[source]#

The observation model for the process

stationary_covariance() tinygp.helpers.JAXArray[source]#

The stationary covariance of the process

to_general_qsm(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) GeneralQSM#

The generalized quasiseparable representation of this kernel

to_symm_qsm(X: tinygp.helpers.JAXArray) SymmQSM#

The symmetric quasiseparable representation of this kernel

transition_matrix(X1: tinygp.helpers.JAXArray, X2: tinygp.helpers.JAXArray) tinygp.helpers.JAXArray[source]#

The transition matrix between two coordinates