firecrown.likelihood.likelihood

firecrown.likelihood.likelihood#

Basic likelihood infrastructure.

This module provides the base class Likelihood, which is the class from which all concrete firecrown likelihoods must descend.

It also provides the function load_likelihood() which reads a likelihood script to create an object of some subclass of Likelihood.

How to use a Likelihood object#

The class Likelihood is designed to support repeated calculations of the likelihood of the observation of some specific data, given a specified theory.

The data for which the likelihood is being calculated is set when the read() method of the likelihood is called. It is expected that this will be done only once in the lifetime of any likelihood object. In the specific case of a GaussFamily likelihood, these data include both a data vector and a covariance matrix, which must be present in the Sacc object given to the read() method.

The theory predictions that are used in the calcluation of a likelihood are expected to change for different calls to the compute_loglike() method. In order to prepare a Likelihood object for each call to compute_loglike(), the following sequence of calls must be made (note that this is done by the Firecrown infrastructure when you are using Firecrown with any of the supported sampling frameworks):

  1. create the Likelihood object like using the concrete class name as a factory function

  2. call read() passing in the sacc.Sacc object containing all the necessary data

  3. for each call to calculate_loglike(), prepare like for the new calculation:

    1. call update() on the ParamsMap object you are using the this likelihood.

    2. call prepare() on the ModelingTools object you are using.

    3. call update() on like, passing in the ParamsMap you just updated.

  4. call calculate_loglike() passing the current ModelingTools object.

  5. call reset() to free any held resources and to prepare like for the next cycle.

Note that repeated calls to update() on a Likelihood object, if there is no intervening call of reset(), have no effect. This is necessary cause the same object many be used in several places in any given Likelihood, but object should only be updated once.

Functions

load_likelihood

Loads a likelihood from the provided likelihood_name.

load_likelihood_from_module

Loads a likelihood from a module.

load_likelihood_from_module_type

Loads a likelihood from a module type.

load_likelihood_from_script

Loads a likelihood script.

Classes

Likelihood

Likelihood is an abstract class.

NamedParameters

Provides access to a set of parameters of a given set of types.