Skip to content

Reference families

The reference backend's samplers and densities beyond the scalar core.

reference_families

The reference backend's samplers and densities beyond the scalar core.

Every family of the semantic registry has a plain-Python sampler and log density here or in :mod:quivers.qiec.distributions, so the reference machine runs any model end to end and can be held to an independent oracle. The structured families work on nested tuples: a vector is a tuple of floats and a matrix a tuple of rows. The small linear algebra they need, Cholesky factors, triangular solves, and determinants, is written out here rather than taken from a host library, which is the point of a reference.

relaxation_temperature

relaxation_temperature(a: Mapping[str, object], family: str) -> float

The temperature a relaxed family is constructed at.

PARAMETER DESCRIPTION
a

The family's named parameters.

TYPE: Mapping[str, object]

family

The family, for the diagnostic.

TYPE: str

RETURNS DESCRIPTION
float

The temperature parameter, or the default when absent.

RAISES DESCRIPTION
DistributionError

If the temperature is not a positive number.

Source code in src/quivers/qiec/reference_families.py
def relaxation_temperature(a: Mapping[str, object], family: str) -> float:
    """The temperature a relaxed family is constructed at.

    Parameters
    ----------
    a : Mapping[str, object]
        The family's named parameters.
    family : str
        The family, for the diagnostic.

    Returns
    -------
    float
        The ``temperature`` parameter, or the default when absent.

    Raises
    ------
    DistributionError
        If the temperature is not a positive number.
    """
    if "temperature" not in a:
        return RELAXATION_TEMPERATURE
    temperature = real_parameter(a, "temperature", family)
    if not temperature > 0.0:
        raise DistributionError(f"{family} needs a positive temperature")
    return temperature