rxmc.correlated_discrepancy_likelihood_model.SklearnKernelGPDiscrepancyModel#

class rxmc.correlated_discrepancy_likelihood_model.SklearnKernelGPDiscrepancyModel(kernel: Kernel, jitter: float = 1e-10, param_prefix: str = 'discrepancy_')[source]#

Bases: ParametricLikelihoodModel

Parametric likelihood with a GP discrepancy covariance term.

Adds a kernel-based GP discrepancy covariance to the observation covariance:

\[\Sigma = \Sigma_{\mathrm{obs}}(y_m) + K_{\mathrm{disc}}(x, x;\,\theta) + \epsilon I\]

The free hyperparameters of the sklearn kernel (those not marked fixed) become likelihood parameters that are sampled alongside the physical-model parameters. sklearn stores hyperparameters in log space via kernel.theta, so the sampled values are also in log space.

Parameters:
  • kernel (sklearn.gaussian_process.kernels.Kernel) – Frozen sklearn kernel. Free hyperparameters (hp.fixed == False) are registered as likelihood parameters.

  • jitter (float, optional) – Small diagonal regularisation added to the GP covariance matrix for numerical stability. Defaults to 1e-10.

  • param_prefix (str, optional) – Prefix applied to each hyperparameter name when building the Parameter list. Defaults to "discrepancy_".

__init__(kernel: Kernel, jitter: float = 1e-10, param_prefix: str = 'discrepancy_')[source]#

Initializes the LikelihoodModel, optionally with a fractional uncorrelated error.

Methods

__init__(kernel[, jitter, param_prefix])

Initializes the LikelihoodModel, optionally with a fractional uncorrelated error.

chi2(observation, ym, *likelihood_params)

Calculate the generalised chi-squared statistic.

covariance(observation, ym, *kernel_theta)

Total covariance: observation covariance plus GP discrepancy.

log_likelihood(observation, ym, ...)

Returns the log likelihood that ym reproduces observation.y

residual(observation, ym)

Return the residual observation.y - ym.

covariance(observation: Observation, ym: ndarray, *kernel_theta)[source]#

Total covariance: observation covariance plus GP discrepancy.

Parameters:
  • observation (Observation) – Observation object.

  • ym (np.ndarray) – Model prediction for the observation.

  • *kernel_theta (float) – Kernel hyperparameter values in sklearn’s log space, one per free hyperparameter of the kernel.

Returns:

np.ndarray, shape (n, n) – Combined covariance matrix.

Raises:

ValueError – If the number of kernel_theta values does not match self.n_params.