Likelihood classes
The inference.likelihoods
module provides tools for constructing likelihood functions.
Example code demonstrating their use can be found in the
Gaussian fitting jupyter notebook demo.
GaussianLikelihood
- class inference.likelihoods.GaussianLikelihood(y_data: ndarray, sigma: ndarray, forward_model: callable, forward_model_jacobian: callable = None)
A class for constructing a Gaussian likelihood function.
- Parameters
y_data – The measured data as a 1D array.
sigma – The standard deviations corresponding to each element in
y_data
as a 1D array.forward_model (callable) – A callable which returns a prediction of the
y_data
values when passed an array of model parameter values.forward_model_jacobian (callable) – A callable which returns the Jacobian of the forward-model when passed an array of model parameter values. The Jacobian is a 2D array containing the derivative of the predictions of each
y_data
value with respect to each model parameter, such that element(i,j)
of the Jacobian corresponds to the derivative of thei
’thy_data
value prediction with respect to thej
’th model parameter.
- __call__(theta)
Returns the log-likelihood value for the given set of model parameters.
- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The log-likelihood value.
- gradient(theta)
Returns the gradient of the log-likelihood with respect to model parameters.
Using this method requires that the
forward_model_jacobian
keyword argument was specified when the instance of the class was created.- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The gradient of the log-likelihood as a 1D
numpy.ndarray
.
CauchyLikelihood
- class inference.likelihoods.CauchyLikelihood(y_data: ndarray, gamma: ndarray, forward_model: callable, forward_model_jacobian: callable = None)
A class for constructing a Cauchy likelihood function.
- Parameters
y_data – The measured data as a 1D array.
gamma – The uncertainties corresponding to each element in
y_data
as a 1D array.forward_model (callable) – A callable which returns a prediction of the
y_data
values when passed an array of model parameter values.forward_model_jacobian (callable) – A callable which returns the Jacobian of the forward-model when passed an array of model parameter values. The Jacobian is a 2D array containing the derivative of the predictions of each
y_data
value with respect to each model parameter, such that element(i,j)
of the Jacobian corresponds to the derivative of thei
’thy_data
value prediction with respect to thej
’th model parameter.
- __call__(theta)
Returns the log-likelihood value for the given set of model parameters.
- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The log-likelihood value.
- gradient(theta)
Returns the gradient of the log-likelihood with respect to model parameters.
Using this method requires that the
forward_model_jacobian
keyword argument was specified when the instance of the class was created.- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The gradient of the log-likelihood as a 1D
numpy.ndarray
.
LogisticLikelihood
- class inference.likelihoods.LogisticLikelihood(y_data: ndarray, sigma: ndarray, forward_model: callable, forward_model_jacobian: callable = None)
A class for constructing a Logistic likelihood function.
- Parameters
y_data – The measured data as a 1D array.
sigma – The uncertainties corresponding to each element in
y_data
as a 1D array.forward_model (callable) – A callable which returns a prediction of the
y_data
values when passed an array of model parameter values.forward_model_jacobian (callable) – A callable which returns the Jacobian of the forward-model when passed an array of model parameter values. The Jacobian is a 2D array containing the derivative of the predictions of each
y_data
value with respect to each model parameter, such that element(i,j)
of the Jacobian corresponds to the derivative of thei
’thy_data
value prediction with respect to thej
’th model parameter.
- __call__(theta)
Returns the log-likelihood value for the given set of model parameters.
- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The log-likelihood value.
- gradient(theta)
Returns the gradient of the log-likelihood with respect to model parameters.
Using this method requires that the
forward_model_jacobian
keyword argument was specified when the instance of the class was created.- Parameters
theta – The model parameters as a 1D
numpy.ndarray
.- Returns
The gradient of the log-likelihood as a 1D
numpy.ndarray
.