alea.models package
Submodules
alea.models.blueice_extended_model module
- class alea.models.blueice_extended_model.BlueiceExtendedModel(parameter_definition: dict, likelihood_config: dict, **kwargs)[source]
Bases:
StatisticalModelA statistical model based on blueice likelihoods.
This class extends the
StatisticalModelclass and provides methods for generating data and computing likelihoods based on blueice.- parameters
Parameters object containing the parameters of the model.
- Type
- _likelihood
A blueice LogLikelihoodSum instance.
- Type
LogLikelihoodSum
- livetime_parameter_names
List of the name of the livetime of each term, None if not specified
- Type
- Parameters
Todo
analysis_space could be inferred from the data (assert that all sources have the same analysis_space)
- __init__(parameter_definition: dict, likelihood_config: dict, **kwargs)[source]
Initialize the statistical model from parameter and likelihood config dicts.
- _build_data_generators() list[source]
Build data generators for all likelihood terms.
- Returns
List of data generators for each likelihood term.
- Return type
Todo
Also implement data generator for ancillary ll term.
- _build_ll_from_config(likelihood_config: dict, template_path: Optional[str] = None) LogLikelihoodSum[source]
Iterate through all likelihood terms and build blueice likelihood instances.
- Parameters
likelihood_config (dict) – A dictionary defining the likelihood.
- Returns
A blueice LogLikelihoodSum instance.
- Return type
LogLikelihoodSum
- _generate_ancillary(**generate_values) dict[source]
Generate data for the ancillary likelihood.
- Keyword Arguments
generate_values (dict) – A dictionary of parameter values.
- Returns
A numpy structured array of ancillary measurements.
- Return type
numpy.array
- _generate_data(**generate_values) dict[source]
Generate data for all likelihood terms and ancillary likelihood.
- _generate_science_data(**generate_values) dict[source]
Generate the science data for all likelihood terms except the ancillary likelihood.
- _process_blueice_config(config, template_folder_list)[source]
Process the blueice config from config.
- _set_default_ptype()[source]
Check if all parameters have a ptype that is in the list of allowed ptypes.
If no ptype is specified, set the default ptype “needs_reinit”.
- _set_efficiency(source: dict, ll)[source]
Set the efficiency of a source in the blueice ll.
- Parameters
source (dict) – A dictionary defining the source.
ll (LogLikelihood) – A blueice LogLikelihood instance.
- Raises
ValueError – If the efficiency_name is not specified in the source.
- property all_source_names: list
Return a sorted list of all source names across all likelihood terms.
- classmethod from_config(config_file_path: str, **kwargs) BlueiceExtendedModel[source]
Initialize the statistical model from a yaml config file.
- Parameters
config_file_path (str) – Path to the yaml config file.
- Returns
Statistical model.
- Return type
- get_expectation_values(per_likelihood_term=False, **kwargs) dict[source]
Return total expectation values summed over all likelihood terms with the same name.
- Parameters
per_likelihood_term (bool) – If True, return expectation values per likelihood term. Otherwise, sum each source over all likelihood terms.
kwargs – Named parameters
- Returns
- Dictionary of expectation values. If per_likelihood_term is True, the dictionary
has the form {likelihood_name: {source_name: expectation_value, …}, …}.
- Return type
Todo
Make a self.likelihood_terms dict with the likelihood names as keys and the corresponding likelihood terms as values.
- get_source_histograms(likelihood_name: str, expected_events=False, **kwargs) dict[source]
Return the pdfs or histograms of all sources for a given likelihood term.
- get_source_name_list(likelihood_name: str) list[source]
Return a list of source names for a given likelihood term.
The order matches the
sourcecolumn of the data, so this can be used to map indices in the data to a source name.
- class alea.models.blueice_extended_model.CustomAncillaryLikelihood(parameters: Parameters)[source]
Bases:
LogAncillaryLikelihoodAncillary likelihood providing constraint terms for nuisance parameters.
Can be used to add constraint terms for parameters of the likelihood.
- parameters
Parameters object containing the parameters to be constrained.
- Type
- __init__(parameters: Parameters)[source]
Initialize the CustomAncillaryLikelihood.
- _get_constraint_functions(**generate_values) dict[source]
Get callable constraint functions for all ancillary parameters.
- Keyword Arguments
generate_values (dict) – A dictionary of parameter values.
- Returns
Dict of constraint functions for all ancillary parameters.
- Return type
Todo
Implement str-type uncertainties.