redback.likelihoods.GaussianLikelihoodWithUpperLimits
- class redback.likelihoods.GaussianLikelihoodWithUpperLimits(*args: Any, **kwargs: Any)[source]
Bases:
GaussianLikelihood- __init__(x: ndarray, y: ndarray, sigma: float | None | ndarray, function: callable, kwargs: dict = None, priors=None, fiducial_parameters=None, detections: ndarray | None = None, upper_limit_sigma: float | ndarray = 3.0, data_mode: str = 'flux') None[source]
A Gaussian likelihood that handles upper limits - extends the base GaussianLikelihood.
- Parameters:
x (np.ndarray) – The x values.
y (np.ndarray) – The y values. For upper limits, these are the reported limit values.
sigma (Union[float, None, np.ndarray]) – The standard deviation of the noise for detections.
function (callable) – The python function to fit to the data. Note, this must take the dependent variable as its first argument. The other arguments will require a prior and will be sampled over (unless a fixed value is given).
kwargs (dict) – Any additional keywords for ‘function’.
priors – The priors for the parameters. Default to None if not provided.
Only necessary if using maximum likelihood estimation functionality. :type priors: Union[dict, None] :param fiducial_parameters: The starting guesses for model parameters to use in the optimization for maximum likelihood estimation. Default to None if not provided. :type fiducial_parameters: Union[dict, None] :param detections: Array indicating which data points are detections. Can be boolean (True/False) or integer (1/0). 1 = detection, 0 = upper limit. If None, all data points are treated as detections. :type detections: Union[np.ndarray, None] :param upper_limit_sigma: The sigma level for upper limits. Can be a single value (e.g., 3.0 for all 3-sigma limits) or an array with different sigma levels for each upper limit. Default is 3.0. :type upper_limit_sigma: Union[float, np.ndarray] :param data_mode: Data units for interpreting upper limits. ‘flux’, ‘flux_density’, and ‘luminosity’ all treat upper limits as “true value < limit”. ‘magnitude’ (or ‘mag’) treats upper limits as “true value > limit” (fainter than limit). Default is ‘flux’. :type data_mode: str
- __call__(*args: Any, **kwargs: Any) Any
Call self as a function.
Methods
__init__(x, y, sigma, function[, kwargs, ...])A Gaussian likelihood that handles upper limits - extends the base GaussianLikelihood.
Estimate the maximum likelihood
get_bounds_from_priors(priors)get_parameter_dictionary_from_list(...)get_parameter_list_from_dictionary(...)Get the sigma values for upper limits only.
lnlike_scipy_maximize(parameter_list)log_likelihood([parameters])Override parent method to include upper limits.
Override parent method to include upper limits in noise likelihood.
summary()Provide a summary of the likelihood setup.
Attributes
data_modedetectionskwargsThe model output for the given x values.
Length of the x/y-values :rtype: int
parametersparameters_to_be_updatedresidualsigmaupper_limit_sigmaupper_limits is the inverse of detections
- find_maximum_likelihood_parameters(iterations=5, maximization_kwargs=None, method='Nelder-Mead', break_threshold=0.001)
Estimate the maximum likelihood
- Parameters:
iterations – Iterations to run the minimizer for before stopping. Default is 5.
maximization_kwargs – Any extra keyword arguments passed to the scipy minimize function
method – Minimize method to use. Default is ‘Nelder-Mead’
break_threshold – The threshold for the difference in log likelihood to break the loop. Default is 1e-3.
- Returns:
Dictionary of maximum likelihood parameters
- get_upper_limit_sigma_values() ndarray[source]
Get the sigma values for upper limits only.
- Returns:
Array of sigma values for upper limit data points.
- Return type:
np.ndarray
- log_likelihood(parameters=None) float[source]
Override parent method to include upper limits.
- Returns:
The log-likelihood including upper limits.
- Return type:
float
- property model_output: ndarray
The model output for the given x values. :rtype: np.ndarray
- Type:
return
- property n: int
Length of the x/y-values :rtype: int
- Type:
return
- noise_log_likelihood() float[source]
Override parent method to include upper limits in noise likelihood.
- Returns:
The noise log-likelihood, i.e. the log-likelihood assuming the signal is just noise.
- Return type:
float
- summary() dict[source]
Provide a summary of the likelihood setup.
- Returns:
Dictionary with summary information
- property upper_limits: ndarray
upper_limits is the inverse of detections
- Type:
Derived property