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):
create the Likelihood object like using the concrete class name as a factory function
call
read()
passing in thesacc.Sacc
object containing all the necessary datafor each call to
calculate_loglike()
, prepare like for the new calculation:call
update()
on theParamsMap
object you are using the this likelihood.call
prepare()
on theModelingTools
object you are using.call
update()
on like, passing in theParamsMap
you just updated.
call
calculate_loglike()
passing the currentModelingTools
object.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
Loads a likelihood from the provided likelihood_name. |
|
Loads a likelihood from a module. |
|
Loads a likelihood from a module type. |
|
Loads a likelihood script. |
Classes
Likelihood is an abstract class. |
|
Provides access to a set of parameters of a given set of types. |