pybop.costs._likelihoods#
Classes#
Base class for likelihoods |
|
This class represents a Gaussian Log Likelihood, which assumes that the |
|
This class represents a Gaussian Log Likelihood with a known sigma, |
|
Maximum a posteriori cost function. |
Module Contents#
- class pybop.costs._likelihoods.BaseLikelihood(problem: pybop.problems.base_problem.BaseProblem)[source]#
Bases:
pybop.costs.base_cost.BaseCostBase class for likelihoods
- class pybop.costs._likelihoods.GaussianLogLikelihood(problem: pybop.problems.base_problem.BaseProblem, sigma0: float | List[float] | List[pybop.parameters.parameter.Parameter] = 0.002, dsigma_scale: float = 1.0)[source]#
Bases:
BaseLikelihoodThis class represents a Gaussian Log Likelihood, which assumes that the data follows a Gaussian distribution and computes the log-likelihood of observed data under this assumption.
This class estimates the standard deviation of the Gaussian distribution alongside the parameters of the model.
- _logpi#
Precomputed offset value for the log-likelihood function.
- Type:
float
- _dsigma_scale#
Scale factor for derivative of standard deviation.
- Type:
float
- _evaluate(inputs: pybop.parameters.parameter.Inputs, grad: None | numpy.ndarray = None) float[source]#
Evaluates the Gaussian log-likelihood for the given parameters.
- Parameters:
inputs (Inputs) – The parameters for which to evaluate the log-likelihood, including the n_outputs standard deviations of the Gaussian distributions.
- Returns:
The log-likelihood value, or -inf if the standard deviations are non-positive.
- Return type:
float
- _evaluateS1(inputs: pybop.parameters.parameter.Inputs) Tuple[float, numpy.ndarray][source]#
Calls the problem.evaluateS1 method and calculates the log-likelihood.
- Parameters:
inputs (Inputs) – The parameters for which to evaluate the log-likelihood.
- Returns:
The log-likelihood and its gradient.
- Return type:
Tuple[float, np.ndarray]
- class pybop.costs._likelihoods.GaussianLogLikelihoodKnownSigma(problem: pybop.problems.base_problem.BaseProblem, sigma0: List[float] | float)[source]#
Bases:
BaseLikelihoodThis class represents a Gaussian Log Likelihood with a known sigma, which assumes that the data follows a Gaussian distribution and computes the log-likelihood of observed data under this assumption.
- Parameters:
sigma0 (scalar or array) – Initial standard deviation around
x0. Either a scalar value (one standard deviation for all coordinates) or an array with one entry per dimension.
- _evaluate(inputs: pybop.parameters.parameter.Inputs, grad: None | numpy.ndarray = None) float[source]#
Evaluates the Gaussian log-likelihood for the given parameters with known sigma.
- class pybop.costs._likelihoods.MAP(problem, likelihood, sigma0=None, gradient_step=0.001)[source]#
Bases:
BaseLikelihoodMaximum a posteriori cost function.
Computes the maximum a posteriori cost function, which is the sum of the log likelihood and the log prior. The goal of maximising is achieved by setting minimising = False in the optimiser settings.
Inherits all parameters and attributes from
BaseLikelihood.- _evaluate(inputs: pybop.parameters.parameter.Inputs, grad=None) float[source]#
Calculate the maximum a posteriori cost for a given set of parameters.
- Parameters:
inputs (Inputs) – The parameters for which to evaluate the cost.
grad (array-like, optional) – An array to store the gradient of the cost function with respect to the parameters.
- Returns:
The maximum a posteriori cost.
- Return type:
float
- _evaluateS1(inputs: pybop.parameters.parameter.Inputs) Tuple[float, numpy.ndarray][source]#
Compute the maximum a posteriori with respect to the parameters. The method passes the likelihood gradient to the optimiser without modification.
- Parameters:
inputs (Inputs) – The parameters for which to compute the cost and gradient.
- Returns:
A tuple containing the cost and the gradient. The cost is a float, and the gradient is an array-like of the same length as x.
- Return type:
tuple
- Raises:
ValueError – If an error occurs during the calculation of the cost or gradient.