firecrown.likelihood.statistic

Gaussian Family Statistic Module.

The Statistic class describing objects that implement methods to compute the data and theory vectors for a GaussFamily subclass.

Exceptions

StatisticUnreadError

Error raised when accessing an un-read statistic.

Classes

Statistic

The abstract base class for all physics-related statistics.

GuardedStatistic

An internal class used to maintain state on statistics.

TrivialStatistic

A minimal statistic only to be used for testing Gaussian likelihoods.

Module Contents

exception firecrown.likelihood.statistic.StatisticUnreadError(stat)[source]

Bases: RuntimeError

Inheritance diagram of firecrown.likelihood.statistic.StatisticUnreadError

Error raised when accessing an un-read statistic.

Run-time error indicating an attempt has been made to use a statistic that has not had read called in it.

Parameters:

stat (Statistic)

statistic
class firecrown.likelihood.statistic.Statistic(parameter_prefix=None)[source]

Bases: firecrown.updatable.Updatable

Inheritance diagram of firecrown.likelihood.statistic.Statistic

The abstract base class for all physics-related statistics.

Statistics read data from a SACC object as part of a multi-phase initialization. They manage a DataVector and, given a ModelingTools object, can compute a TheoryVector.

Statistics represent things like two-point functions and mass functions.

Parameters:

parameter_prefix (None | str)

sacc_indices: None | numpy.typing.NDArray[numpy.int64]
ready = False
computed_theory_vector = False
theory_vector: None | firecrown.data_types.TheoryVector = None
read(_)[source]

Read the data for this statistic and mark it as ready for use.

Derived classes that override this function should make sure to call the base class method using:

super().read(sacc_data)

as the last thing they do.

Parameters:

_ (sacc.Sacc) – currently unused, but required by the interface.

Return type:

None

abstractmethod get_data_vector()[source]

Gets the statistic data vector.

Returns:

The data vector.

Return type:

firecrown.data_types.DataVector

compute_theory_vector(tools)[source]

Compute a statistic from sources, applying any systematics.

Parameters:

tools (firecrown.modeling_tools.ModelingTools) – the modeling tools used to compute the theory vector.

Returns:

The computed theory vector.

Return type:

firecrown.data_types.TheoryVector

get_theory_vector()[source]

Returns the last computed theory vector.

Raises a RuntimeError if the vector has not been computed.

Returns:

The already-computed theory vector.

Return type:

firecrown.data_types.TheoryVector

class firecrown.likelihood.statistic.GuardedStatistic(stat)[source]

Bases: firecrown.updatable.Updatable

Inheritance diagram of firecrown.likelihood.statistic.GuardedStatistic

An internal class used to maintain state on statistics.

GuardedStatistic is used by the framework to maintain and validate the state of instances of classes derived from Statistic.

Parameters:

stat (Statistic)

statistic
read(sacc_data)[source]

Read whatever data is needed from the given sacc.Sacc object.

After this function is called, the object should be prepared for the calling of the methods get_data_vector() and compute_theory_vector().

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to read from.

Return type:

None

get_data_vector()[source]

Return the contained Statistic’s data vector.

GuardedStatistic ensures that read() has been called. first.

Returns:

The most recently calculated data vector.

Return type:

firecrown.data_types.DataVector

compute_theory_vector(tools)[source]

Return the contained Statistic’s computed theory vector.

GuardedStatistic ensures that read() has been called. first.

Parameters:

tools (firecrown.modeling_tools.ModelingTools) – the modeling tools used to compute the theory vector.

Returns:

The computed theory vector.

Return type:

firecrown.data_types.TheoryVector

class firecrown.likelihood.statistic.TrivialStatistic[source]

Bases: Statistic

Inheritance diagram of firecrown.likelihood.statistic.TrivialStatistic

A minimal statistic only to be used for testing Gaussian likelihoods.

It returns a DataVector and TheoryVector each of which is three elements long. The SACC data provided to TrivialStatistic.read() must supply the necessary values.

count = 3
data_vector: None | firecrown.data_types.DataVector = None
mean
computed_theory_vector = False
read(sacc_data)[source]

Read the necessary items from the sacc data.

Parameters:

sacc_data (sacc.Sacc) – The SACC data object to be read

Return type:

None

get_data_vector()[source]

Return the data vector; raise exception if there is none.

Returns:

The data vector.

Return type:

firecrown.data_types.DataVector