rxmc.likelihood_model.FixedCovarianceLikelihood#

class rxmc.likelihood_model.FixedCovarianceLikelihood[source]#

Bases: LikelihoodModel

A special LikelihoodModel to handle FixedCovarianceObservation objects, where the covariance matrix is fixed and does not depend on the parameters of the PhysicalModel.

This allows for the use of precomputed inverse covariance matrices which can speed up the calculation of the chi-squared statistic and log_likelihood.

__init__()[source]#

Initializes the LikelihoodModel, optionally with a fractional uncorrelated error.

Methods

__init__()

Initializes the LikelihoodModel, optionally with a fractional uncorrelated error.

chi2(observation, ym)

Calculate the generalised chi-squared statistic.

covariance(observation, ym)

Returns the fixed covariance matrix in observation

log_likelihood(observation, ym)

Returns the log_likelihood that ym reproduces y, given the fixed covariance matrix

residual(observation, ym)

Return the residual observation.y - ym.

covariance(observation: FixedCovarianceObservation, ym: ndarray)[source]#

Returns the fixed covariance matrix in observation

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

  • observation (FixedCovarianceObservation) – The observation object containing the observed data, which has attribute covariance.

Returns:

np.ndarray – Fixed covariance matrix.

chi2(observation: FixedCovarianceObservation, ym: ndarray)[source]#

Calculate the generalised chi-squared statistic. This is the Mahalanobis distance between y and ym

Parameters:
  • params (OrderedDict) – parameters of model

  • observation (FixedCovarianceObservation) – The observation object containing the observed data, which has attribute cov_inv.

Returns:

float – Chi-squared statistic.

log_likelihood(observation: FixedCovarianceObservation, ym: ndarray)[source]#

Returns the log_likelihood that ym reproduces y, given the fixed covariance matrix

Parameters:
  • params (OrderedDict) – parameters of model

  • observation (FixedCovarianceObservation) – The observation object containing the observed data, which has attributes cov_inv, n_data_pts and log_det.

Returns:

float