The Likelihoods module

class midas.likelihoods.DiagnosticLikelihood(diagnostic_model, likelihood, name)

A class enabling the calculation of the likelihood (and its derivative) for the data of a particular diagnostic.

Parameters:
  • diagnostic_model (DiagnosticModel) – An instance of a diagnostic model which inherits from the DiagnosticModel base class.

  • likelihood (LikelihoodFunction) – An instance of a likelihood class which inherits from the LikelihoodFunction base class.

  • name (str) – A name or other identifier for the diagnostic as a string.

Built-in likelihood functions

Likelihood functions, which model the uncertainties associated with measured data as various probability distributions, are implemented as classes in MIDAS which also encapsulate the measured data and their estimated uncertainties.

class midas.likelihoods.GaussianLikelihood(y_data, sigma)

A class for constructing a Gaussian likelihood function.

Parameters:
  • y_data (ndarray) – The measured data as a 1D array.

  • sigma (ndarray | UncertaintyModel) – The standard deviations corresponding to each element in y_data as a 1D array. Alternatively, a model for the uncertainties (inheriting from the UncertaintyModel base-class) can be provided, allowing the uncertainties to be parameterised and inferred.

class midas.likelihoods.LogisticLikelihood(y_data, sigma)

A class for constructing a Logistic likelihood function.

Parameters:
  • y_data (ndarray) – The measured data as a 1D array.

  • sigma (ndarray | UncertaintyModel) – The uncertainties corresponding to each element in y_data as a 1D array. Alternatively, a model for the uncertainties (inheriting from the UncertaintyModel base-class) can be provided, allowing the uncertainties to be parameterised and inferred.

class midas.likelihoods.CauchyLikelihood(y_data, gamma)

A class for constructing a Cauchy likelihood function.

Parameters:
  • y_data (ndarray) – The measured data as a 1D array.

  • gamma (ndarray | UncertaintyModel) – The uncertainties corresponding to each element in y_data as a 1D array. Alternatively, a model for the uncertainties (inheriting from the UncertaintyModel base-class) can be provided, allowing the uncertainties to be parameterised and inferred.

Uncertainty models

As an alternative to passing fixed estimates of the uncertainties on measured data to likelihood function classes, a model for the uncertainties can be given instead, allowing them to vary.

class midas.likelihoods.ConstantUncertainty(n_data, parameter_name)

Models the certainty on a set of data given to a likelihood function as a single value shared by all the data.

Parameters:
  • n_data (int) – The number data points for which uncertainties are being modelled.

  • parameter_name (str) – The name of the parameter which sets the uncertainty value for all data points.

class midas.likelihoods.LinearUncertainty(y_data, parameter_prefix)

Models the certainty on a set of data given to a likelihood function as a linear function of the data values.

Parameters:
  • y_data (ndarray) – The data values given to the likelihood function as a 1D array.

  • parameter_prefix (str) – A prefix added to the names of the parameters specifying the fractional and constant components of the modelled uncertainties.

Abstract base classes

class midas.likelihoods.LikelihoodFunction

An abstract base-class for likelihood function.

abstractmethod log_likelihood(predictions, **parameters)
Parameters:
  • predictions (ndarray) – The model predictions of the measured data as a 1D array.

  • parameters (ndarray)

Returns:

The calculated log-likelihood.

Return type:

float

class midas.likelihoods.UncertaintyModel

An abstract base-class for uncertainty models.

abstractmethod get_uncertainties(parameters)

Get the values of the uncertainties.

Parameters:

parameters (dict[str, ndarray]) – The parameter values requested via the ParameterVector objects stored in the parameters instance attribute. These values are given as a dictionary mapping the parameter names (specified by the name attribute of the ParameterVector objects) to the parameter values as 1D arrays.

Returns:

The modelled uncertainty values as a 1D array.

Return type:

ndarray

abstractmethod get_uncertainties_and_jacobians(parameters)

Get the values of the uncertainties, and the Jacobians of the uncertainties values with respect to the given parameters values.

Parameters:

parameters (dict[str, ndarray]) – The parameter values requested via the ParameterVector objects stored in the parameters instance attribute. These values are given as a dictionary mapping the parameter names (specified by the name attribute of the ParameterVector objects) to the parameter values as 1D arrays.

Returns:

The uncertainty values as a 1D array, followed by the Jacobians of the uncertainties with respect to the given parameter values.

The Jacobians must be returned as a dictionary mapping the parameter names to the corresponding Jacobians as 2D arrays.

Return type:

tuple[ndarray, dict[str, ndarray]]