Likelihood#
- class cosmicjellyfish.likelihood.base.Likelihood(*, cosmo_data, cosmo_theory=None, leg_flag='wedges')[source]#
Bases:
ABCCommon interface for likelihood evaluations used in Cosmicjellyfish.
This abstract base class defines the core interface for likelihood calculations in Cosmicjellyfish. It provides methods for computing data representations, theory predictions, and chi-squared values, as well as utilities for parameter handling and running Nautilus samplers.
- abstract compute_data()[source]#
Compute and return the observed data representation.
This method should be implemented by subclasses to return the data in the appropriate format (e.g., wedges or multipoles) for likelihood calculations.
- Return type:
- Returns:
The observed data representation
- abstract compute_theory(param_dict)[source]#
Compute and return the theory prediction.
This method should be implemented by subclasses to return the theory prediction in the same representation as the observed data.
- abstract compute_chi2(theory_obs)[source]#
Compute and return the chi-squared value.
This method should be implemented by subclasses to compute the chi-squared value between the observed data and theory prediction.
- build_param_dict(*, param_vec=None, param_dict=None, prior=None)[source]#
Create a parameter dictionary from vector inputs when needed.
This method converts a parameter vector to a dictionary using the prior information, or returns the provided parameter dictionary directly.
- Parameters:
- Return type:
- Returns:
Dictionary of parameters
- Raises:
ValueError – If neither param_dict nor (param_vec and prior) are provided
TypeError – If param_vec is not an indexable iterable
AttributeError – If prior object doesn’t expose an ordered ‘keys’ attribute
- loglike(param_vec=None, *, param_dict=None, prior=None)[source]#
Compute the log-likelihood value.
This method computes the log-likelihood value (-0.5 * χ²) for the supplied parameters. It can accept either a parameter vector or a parameter dictionary.
- Parameters:
- Return type:
- Returns:
The log-likelihood value (-0.5 * χ²)