Likelihood

Similar to component, Likelihood takes all registered Component and compares it with data, and calulate binned Poisson log likelihood. The base is

class appletree.Likelihood(name: Optional[str] = None, **config)[source]

Bases: object

Combine all components (e.g. ER, AC, Wall), and calculate log posterior likelihood.

__getitem__(keys)[source]

Get component in likelihood.

__init__(name: Optional[str] = None, **config)[source]

Create an appletree likelihood.

Parameters

config – Dictionary with configuration options that will be applied, should include: * data_file_name: the data used in fitting, usually calibration data * bins_type: either meshgrid or equiprob * bins_on: observables where we will perform inference on, usually [cs1, cs2] * x_clip, y_clip: ROI of the fitting, should be list of upper and lower boundary * parameter_alias: alias of parameters that will be renamed from key to value

_make_data_hist(use_meshgrid=False)[source]

Create the data histogram from self.data and self._bins.

_print_components(indent: str = '    ', short: bool = True)[source]

Print component details shared by Likelihood and LikelihoodLit.

_resolve_bin_edges(bin_spec, clip_range, config, warn_key)[source]

Resolve a single axis bin specification into bin edges.

Parameters
  • bin_spec – int (number of bins) or array-like (explicit edges).

  • clip_range – tuple of (lo, hi) for linspace when bin_spec is int.

  • config – the full config dict.

  • warn_key – config key (e.g. “x_clip”) to check for spurious warning.

_resolve_explicit_bins(config)[source]

Resolve explicit bin specs (meshgrid or irreg) into a tuple of arrays.

_sanity_check()[source]

Check equality between number of bins group and observables.

_validate_irreg_bins_2d()[source]

Validate irregular 2D bins: x-bins length and y-bins uniformity.

get_log_likelihood(*args, **kwargs)[source]
get_num_events_accepted(*args, **kwargs)[source]
property lineage
property lineage_hash
print_likelihood_summary(indent: str = '    ', short: bool = True)[source]

Print likelihood summary: components, bins, file names.

Parameters
  • indent – str of indent.

  • short – bool, whether only print short summary.

register_component(component_cls: Type[Component], component_name: str, file_name: Optional[str] = None)[source]

Create an appletree likelihood.

Parameters
  • component_cls – class of Component.

  • component_name – name of Component.

  • file_name – file used in ComponentFixed.

replace_alias(parameters)[source]

Replace alias in parameters from key to value.

Note that the value will be popped out.

set_binning(config)[source]

Set binning of likelihood.

simulate_weighted_data(*args, **kwargs)[source]

See also