Reference support¶
These helpers implement the numerical operations that the reference distributions share, including parameter validation and conversion. A discrepancy in a family's sampling or density may trace back to them.
reference_support
¶
Shared helpers of the reference distribution backend.
The argument readers, scalar special functions, and the sampler and density signatures live here so the family tables can be split across modules without any of them importing the backend that installs them.
DistributionError
¶
Bases: ValueError
A distribution could not be constructed, sampled, or scored.
real_parameter
¶
Read one real-valued parameter.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The named parameters.
TYPE:
|
name
|
The parameter wanted.
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The parameter as a float. |
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If the parameter is absent or not a number. |
Source code in src/quivers/qiec/reference_support.py
vector_parameter
¶
Read one vector-valued parameter.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The named parameters.
TYPE:
|
name
|
The parameter wanted.
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[float, ...]
|
The parameter's components. |
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If the parameter is absent or not a sequence of numbers. |
Source code in src/quivers/qiec/reference_support.py
probability
¶
The success probability of a Bernoulli-like family.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The named parameters, holding
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The probability, from |
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If neither parameterization is supplied. |
Source code in src/quivers/qiec/reference_support.py
log_probabilities
¶
The log success and log failure probability of a Bernoulli-like family.
From logits both come through the softplus, log p = -softplus(-l)
and log (1 - p) = -softplus(l), which stay finite and accurate where
the probability itself rounds to zero or one.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The named parameters, holding
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[float, float]
|
|
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If neither parameterization is supplied. |
Source code in src/quivers/qiec/reference_support.py
simplex
¶
The category probabilities of a categorical-like family.
| PARAMETER | DESCRIPTION |
|---|---|
arguments
|
The named parameters, holding
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[float, ...]
|
Probabilities summing to one, from |
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If neither parameterization is supplied or weights are invalid. |
Source code in src/quivers/qiec/reference_support.py
log_choose
¶
log C(n, k) through the log-gamma function.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
The number of trials.
TYPE:
|
k
|
The number of successes.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The log binomial coefficient. |
Source code in src/quivers/qiec/reference_support.py
normal_log_prob
¶
The log density of a normal distribution.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The point.
TYPE:
|
loc
|
The mean.
TYPE:
|
scale
|
The standard deviation.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The log density. |
Source code in src/quivers/qiec/reference_support.py
finite_value
¶
Read the point a scalar family is scored at.
| PARAMETER | DESCRIPTION |
|---|---|
value
|
The point.
TYPE:
|
family
|
The family, for the diagnostic.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
float
|
The point as a float. |
| RAISES | DESCRIPTION |
|---|---|
DistributionError
|
If the point is not a number. |