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, |
|
The Log Posterior for a given problem. |
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.01, 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.
- compute(y: dict, dy: numpy.ndarray = None, calculate_grad: bool = False) float | tuple[float, numpy.ndarray][source]#
Compute the Gaussian log-likelihood for the given parameters.
This method only computes the likelihood, without calling problem.evaluate().
- Returns:
The log-likelihood value, or -inf if the standard deviations are non-positive.
- Return type:
float
- 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.
- class pybop.costs._likelihoods.LogPosterior(log_likelihood: BaseLikelihood, log_prior: pybop.BasePrior | scipy.stats.rv_continuous | None = None, gradient_step: float = 0.001)[source]#
Bases:
BaseLikelihoodThe Log Posterior for a given problem.
Computes the log posterior which is proportional to the sum of the log likelihood and the log prior.
- Parameters:
log_likelihood (BaseLikelihood) – The likelihood class of type
BaseLikelihood.log_prior (Optional, 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_step (float, default: 1e-3) – The step size for the finite-difference gradient calculation if the
log_prioris not of typeBasePrior.
- compute(y: dict, dy: numpy.ndarray = None, calculate_grad: bool = False) float | tuple[float, numpy.ndarray][source]#
Calculate the posterior cost for a given forward model prediction.
- Parameters:
y (dict) – The data for which to evaluate the cost.
dy (np.ndarray, optional) – The correspond sensitivities in the data.
calculate_grad (bool, optional) – Whether to calculate the gradient of the cost function.
- Returns:
The posterior cost, and optionally the gradient.
- Return type:
Union[float, Tuple[float, np.ndarray]]
- property likelihood: BaseLikelihood[source]#
- property prior: pybop.parameters.priors.BasePrior[source]#