threeML.classicMLE.joint_likelihood module
- class threeML.classicMLE.joint_likelihood.JointLikelihood(likelihood_model: Model, data_list: DataList, verbose: bool = False, record: bool = True)[source]
Bases:
object
- property analysis_type: str
- compute_TS(source_name, alt_hyp_mlike_df)[source]
Computes the Likelihood Ratio Test statistic (TS) for the provided source
- Parameters:
source_name – name for the source
alt_hyp_mlike_df – likelihood dataframe (it is the second output of the .fit() method)
- Returns:
a DataFrame containing the null hypothesis and the alternative hypothesis -log(likelihood) values and
the value for TS for the source for each loaded dataset
- property correlation_matrix
correlation matrix from the last fit
- Type:
return
- property covariance_matrix
covariance matrix from the last fit
- Type:
return
- property current_minimum: float
current minimum of the joint likelihood (available only after the fit() method)
- Type:
return
- fit(quiet: bool = False, compute_covariance: bool = True, n_samples: int = 5000)[source]
Perform a fit of the current likelihood model on the datasets
- Parameters:
quiet – If True, print the results (default), otherwise do not print anything
:param compute_covariance:If True (default), compute and display the errors and the correlation matrix. :param n_samples: Number of samples to scan the likelihood. :return: a dictionary with the results on the parameters, and the values of the likelihood at the minimum
for each dataset and the total one.
- property fit_trace
- get_contours(param_1, param_1_minimum, param_1_maximum, param_1_n_steps, param_2=None, param_2_minimum=None, param_2_maximum=None, param_2_n_steps=None, progress=True, **options)[source]
Generate confidence contours for the given parameters by stepping for the given number of steps between the given boundaries. Call it specifying only source_1, param_1, param_1_minimum and param_1_maximum to generate the profile of the likelihood for parameter 1. Specify all parameters to obtain instead a 2d contour of param_1 vs param_2.
NOTE: if using parallel computation, param_1_n_steps must be an integer multiple of the number of running engines. If that is not the case, the code will reduce the number of steps to match that requirement, and issue a warning
- Parameters:
param_1 – fully qualified name of the first parameter or parameter instance
param_1_minimum – lower bound for the range for the first parameter
param_1_maximum – upper bound for the range for the first parameter
param_1_n_steps – number of steps for the first parameter
param_2 – fully qualified name of the second parameter or parameter instance
param_2_minimum – lower bound for the range for the second parameter
param_2_maximum – upper bound for the range for the second parameter
param_2_n_steps – number of steps for the second parameter
progress – (True or False) whether to display progress or not
log – by default the steps are taken linearly. With this optional parameter you can provide a tuple of booleans which specify whether the steps are to be taken logarithmically. For example, ‘log=(True,False)’ specify that the steps for the first parameter are to be taken logarithmically, while they are linear for the second parameter. If you are generating the profile for only one parameter, you can specify ‘log=(True,)’ or ‘log=(False,)’ (optional)
- Returns:
a tuple containing an array corresponding to the steps for the first parameter, an array corresponding to the steps for the second parameter (or None if stepping only in one direction), a matrix of size param_1_steps x param_2_steps containing the value of the function at the corresponding points in the grid. If param_2_steps is None (only one parameter), then this reduces to an array of size param_1_steps.
- get_errors(quiet=False)[source]
Compute the errors on the parameters using the profile likelihood method.
- Returns:
a dictionary containing the asymmetric errors for each parameter.
- property likelihood_model: Model
likelihood model for this analysis
- Type:
return
- property minimizer
an instance of the minimizer used in the fit (available only after the fit() method)
- Type:
return
- property minimizer_in_use
- minus_log_like_profile(*trial_values)[source]
Return the minus log likelihood for a given set of trial values
- Parameters:
trial_values – the trial values. Must be in the same number as the free parameters in the model
- Returns:
minus log likelihood
- property results: MLEResults
- set_minimizer(minimizer)[source]
Set the minimizer to be used, among those available.
- Parameters:
minimizer – the name of the new minimizer or an instance of a LocalMinimization or a GlobalMinimization
class. Using the latter two classes allows for more choices and a better control of the details of the minimization, like the choice of algorithms (if supported by the used minimizer) :return: (none)