pybop.costs.likelihoods#
Classes#
This class represents a Gaussian log-likelihood, which computes the log-likelihood under |
|
This class represents a Gaussian log-likelihood with a known sigma, which computes the |
|
Base class for likelihoods. |
|
The log-posterior defined as the sum of the log-likelihood and the log-prior. |
Module Contents#
- class pybop.costs.likelihoods.GaussianLogLikelihood(dataset: pybop._dataset.Dataset, sigma0: float | list[float] | list[pybop.parameters.parameter.Parameter] = 0.01, dsigma_scale: float = 1.0, target: str | list[str] = None)[source]#
Bases:
LogLikelihoodThis class represents a Gaussian log-likelihood, which computes the log-likelihood under the assumption that measurement noise on the target data follows a Gaussian distribution.
This class estimates the standard deviation of the Gaussian distribution alongside the parameters of the model.
- __call__(r: numpy.ndarray, dy: numpy.ndarray | None = None) float | tuple[float, numpy.ndarray][source]#
Compute the Gaussian log-likelihood for the given parameters.
- set_sigma0(sigma0: float | list[float] | list[pybop.parameters.parameter.Parameter])[source]#
Set sigma0 after checking its validity.
- class pybop.costs.likelihoods.GaussianLogLikelihoodKnownSigma(dataset: pybop._dataset.Dataset, sigma0: list[float] | float, target: str | list[str] = None)[source]#
Bases:
LogLikelihoodThis class represents a Gaussian log-likelihood with a known sigma, which computes the log-likelihood under the assumption that measurement noise on the target data follows a Gaussian distribution.
- 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.
- class pybop.costs.likelihoods.LogLikelihood(dataset: pybop._dataset.Dataset, target: str | list[str] = None)[source]#
Bases:
pybop.costs.error_measures.ErrorMeasureBase class for likelihoods.
Exists to distinguish between error measures and likelihood-based costs.
- class pybop.costs.likelihoods.LogPosterior(log_likelihood: LogLikelihood, prior: pybop.parameters.priors.BasePrior | scipy.stats.rv_continuous | None = None, gradient_step: float = 0.001)[source]#
Bases:
LogLikelihoodThe log-posterior defined as the sum of the log-likelihood and the log-prior.
Additional Parameters#
- log_likelihoodLogLikelihood
The likelihood class of type
LogLikelihood.- priorOptional, Union[pybop.BasePrior, stats.rv_continuous]
The prior class of type
BasePriororstats.rv_continuous. If not provided, the prior class will be taken from the parameter priors constructed in the pybop.Parameters class.- gradient_stepfloat, default: 1e-3
The step size for the finite-difference gradient calculation
- __call__(r: numpy.ndarray, dy: numpy.ndarray | None = None) float | tuple[float, numpy.ndarray][source]#
Computes the cost function for the given predictions.
- Parameters:
r (np.ndarray) – The residual difference between the model prediction and the target. The dimensions of r are (len(target), len(domain_data)).
dy (np.ndarray, optional) – The corresponding gradient with respect to the parameters for each output variable. The dimensions of dy are (len(parameters), len(target), len(domain_data)).
- Returns:
If dy is not None, returns a tuple containing the cost (float) and the gradient with dimension (len(parameters)), otherwise returns only the cost.
- Return type:
np.float64 or tuple[np.float64, np.ndarray[np.float64]]