Continuous Families¶
Families of continuous-valued distributions.
families
¶
Parameterized distribution families as continuous morphisms.
Each family is a ContinuousMorphism whose codomain is a continuous space and whose conditional distribution p(y | x) belongs to a specific parametric family. The parameters are learnable functions of x:
- For discrete domains (FinSet): parameters are looked up from a table.
- For continuous domains (ContinuousSpace): parameters are produced by a small neural network.
This module wraps every reparameterizable distribution in torch.distributions as a conditional morphism, plus custom families (TruncatedNormal, MultivariateNormal, etc.).
Architecture
Most per-dimension-independent distributions are built on a shared
generic base _IndependentConditional that handles the parameter
source, transform, and torch.distributions plumbing. The
_make_family class factory generates named classes from a
specification. Distributions that need special handling
(MultivariateNormal, Dirichlet, TruncatedNormal, etc.) are
implemented as standalone classes.
ConditionalNormal
¶
ConditionalNormal(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source=None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional normal (Gaussian) distribution.
For each input x, produces an independent normal distribution on each dimension of the codomain:
y_i ~ Normal(mu_i(x), sigma_i(x))
Parameters are learnable: mu and log(sigma) are functions of x, implemented as lookup tables (discrete domain) or neural networks (continuous domain).
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Examples:
>>> from quivers import FinSet
>>> from quivers.continuous.spaces import Euclidean
>>> A = FinSet(name="context", cardinality=5)
>>> Y = Euclidean(name="response", dim=3)
>>> f = ConditionalNormal(A, Y)
>>> x = torch.tensor([0, 1, 2])
>>> samples = f.rsample(x) # shape (3, 3)
Source code in src/quivers/continuous/families.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
ConditionalLogitNormal
¶
ConditionalLogitNormal(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional logit-normal distribution on (0, 1)^d.
If z ~ Normal(mu(x), sigma(x)), then y = sigmoid(z) ~ LogitNormal. Useful for modeling probabilities and bounded quantities.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (should have bounds [0, 1]).
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
ConditionalBeta
¶
ConditionalBeta(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional beta distribution on (0, 1)^d.
For each input x, produces an independent Beta(alpha_i(x), beta_i(x)) on each dimension of the codomain.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (should have bounds [0, 1]).
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
ConditionalTruncatedNormal
¶
ConditionalTruncatedNormal(domain: AnySpace, codomain: Euclidean, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional truncated normal on [low, high]^d.
A normal distribution restricted to a bounded interval. Uses rejection-free sampling via the inverse CDF (Phi-based) method.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (must be bounded).
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 | |
ConditionalDirichlet
¶
ConditionalDirichlet(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Dirichlet distribution on a probability simplex.
For each input x, produces a Dirichlet(alpha(x)) distribution on the simplex.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target simplex.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | |
ConditionalUniform
¶
ConditionalUniform(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional uniform distribution on a learnable interval.
Parameterized as Uniform(loc - width/2, loc + width/2) where loc is unconstrained and width is positive. This ensures low < high is always satisfied.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 | |
ConditionalMultivariateNormal
¶
ConditionalMultivariateNormal(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional multivariate normal with full covariance.
Parameterized via Cholesky factor: the parameter source outputs loc (d values) and the lower-triangular entries of L (d*(d+1)/2 values), where Sigma = L @ L^T.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (d-dimensional).
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 | |
ConditionalLowRankMVN
¶
ConditionalLowRankMVN(domain: AnySpace, codomain: ContinuousSpace, rank: int = 2, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional low-rank multivariate normal.
Parameterized as loc + low-rank factor + diagonal: Sigma = W @ W^T + diag(d)
This is more parameter-efficient than full MVN for high dimensions.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (d-dimensional).
TYPE:
|
rank
|
Rank of the low-rank factor W.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | |
ConditionalRelaxedBernoulli
¶
ConditionalRelaxedBernoulli(domain: AnySpace, codomain: ContinuousSpace, temperature: float = 0.5, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional relaxed Bernoulli (concrete) distribution.
Outputs continuous values in (0, 1) that approximate Bernoulli samples. The temperature controls the relaxation: lower temperature = closer to discrete.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (should be 1-d per Bernoulli component).
TYPE:
|
temperature
|
Relaxation temperature.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | |
ConditionalRelaxedOneHotCategorical
¶
ConditionalRelaxedOneHotCategorical(domain: AnySpace, codomain: ContinuousSpace, temperature: float = 0.5, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional relaxed one-hot categorical (Gumbel-Softmax).
Outputs continuous vectors on the simplex that approximate one-hot categorical samples.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space (simplex or d-dimensional).
TYPE:
|
temperature
|
Relaxation temperature.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 | |
ConditionalWishart
¶
ConditionalWishart(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Wishart distribution over positive-definite matrices.
Produces random d x d positive-definite matrices. Parameterized by degrees of freedom df(x) and a scale matrix V(x).
The codomain dimension is interpreted as d, and outputs are d x d matrices flattened to d^2.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space. dim is the matrix size d (output is d x d).
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 | |
ConditionalMatrixNormal
¶
ConditionalMatrixNormal(domain: AnySpace, codomain: ContinuousSpace, rows: int, cols: int, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Matrix-Normal :math:\mathcal{MN}(M, U, V).
The matrix-Normal distribution on :math:\mathbb{R}^{n \times p}
factorises with a Kronecker-product covariance: if
:math:X \sim \mathcal{MN}(M, U, V) then
:math:\mathrm{vec}(X) \sim \mathcal{N}(\mathrm{vec}(M), V \otimes U)
with :math:U \in \mathbb{R}^{n \times n} the row covariance
and :math:V \in \mathbb{R}^{p \times p} the column covariance.
Categorically, the Kronecker structure is the tensor product
of two Gaussians; it is strictly more constrained than the
flat :math:np-dim MVN that the same parameter tensor could
carry, so the surface keeps the two families distinct (no
auto-substitution). Use this when the prior should express
independent row and column correlation structure.
The codomain's product factorisation supplies the row and
column dimensions. The grammar surface
~ MatrixNormal(loc, row_scale, col_scale) over (dom, cod)
binds the first axis listed in over to the row covariance
and the second to the column covariance.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space whose factorisation supplies
TYPE:
|
rows
|
Row dimension :math:
TYPE:
|
cols
|
Column dimension :math:
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter network.
TYPE:
|
Source code in src/quivers/continuous/families.py
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 | |
ConditionalInverseWishart
¶
ConditionalInverseWishart(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Inverse-Wishart over positive-definite matrices.
Conjugate prior for the covariance of a multivariate normal.
Realised as a deterministic inversion of a Wishart sample so
autograd flows; equivalent in distribution to drawing
:math:\Sigma^{-1} \sim \mathcal{W}(\nu, V^{-1}) and
inverting. See Gelman et al. (2013) §3.6 for the conjugacy
statement.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space whose
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter network.
TYPE:
|
Source code in src/quivers/continuous/families.py
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 | |
ConditionalBernoulli
¶
ConditionalBernoulli(domain: AnySpace, codomain: AnySpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Bernoulli: continuous probability -> discrete truth value.
Takes a continuous input x and produces learnable logits that parameterize a Bernoulli distribution. The output is a discrete sample in {0, 1}, returned as a LongTensor.
This is the key bridge used in PDS (Grove & White) for the
Bern x pattern, where a LogitNormal draw x in (0,1)
parameterizes a Bernoulli over truth values.
The codomain must be a FinSet of size 2 (representing {False, True} or {0, 1}).
Note
Sampling from Bernoulli is NOT reparameterizable. Gradients do not flow through the discrete samples. Use score function estimators (REINFORCE) or the Gumbel-Softmax trick if differentiable samples are needed.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space (typically UnitInterval or a FinSet).
TYPE:
|
codomain
|
Target FinSet of size 2.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | |
log_prob
¶
log_prob(x: Tensor, y: Tensor) -> Tensor
Log-probability of discrete output y given input x.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor.
TYPE:
|
y
|
Discrete output in {0, 1}. Shape (batch,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log-probabilities. Shape (batch,). |
Source code in src/quivers/continuous/families.py
1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 | |
rsample
¶
rsample(x: Tensor, sample_shape: Size = Size()) -> Tensor
Sample from Bernoulli (not reparameterizable).
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor.
TYPE:
|
sample_shape
|
Additional leading sample dimensions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Discrete samples in {0, 1}. Shape (*sample_shape, batch). |
Source code in src/quivers/continuous/families.py
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 | |
ConditionalCategorical
¶
ConditionalCategorical(domain: AnySpace, codomain: AnySpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Categorical: continuous input -> discrete category.
Generalizes ConditionalBernoulli to k > 2 categories. Takes a continuous input and produces learnable logits over k categories. The output is a discrete sample in {0, ..., k-1}.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target FinSet of size k.
TYPE:
|
hidden_dim
|
Hidden layer width for neural parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 | |
log_prob
¶
log_prob(x: Tensor, y: Tensor) -> Tensor
Log-probability of discrete output y given input x.
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor.
TYPE:
|
y
|
Discrete output in {0, ..., k-1}. Shape (batch,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Log-probabilities. Shape (batch,). |
Source code in src/quivers/continuous/families.py
1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 | |
rsample
¶
rsample(x: Tensor, sample_shape: Size = Size()) -> Tensor
Sample from Categorical (not reparameterizable).
| PARAMETER | DESCRIPTION |
|---|---|
x
|
Input tensor.
TYPE:
|
sample_shape
|
Additional leading sample dimensions.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Discrete samples in {0, ..., k-1}. Shape (*sample_shape, batch). |
Source code in src/quivers/continuous/families.py
1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 | |
ConditionalBinomial
¶
ConditionalBinomial(domain: AnySpace, codomain: ContinuousSpace, total_count: int = 1, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional Binomial(total_count, probs(x)).
The total_count (number of trials) is a fixed
hyperparameter set at construction time — typical for binomial
likelihoods where n is known per observation. Only the
probs parameter is learnable.
Outputs integer counts in {0, 1, ..., total_count}.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space.
TYPE:
|
total_count
|
Number of Bernoulli trials per observation.
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 | |
ConditionalLogisticNormal
¶
ConditionalLogisticNormal(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional LogisticNormal on the simplex.
Pushes a Normal(loc(x), scale(x)) draw through the softmax
transform to produce a simplex-valued sample. Multivariate
analogue of ConditionalLogitNormal. Useful as an
alternative to ConditionalDirichlet when the
underlying simplex distribution should be Gaussian in
logit space rather than Beta-shaped.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space;
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 | |
ConditionalOrderedLogistic
¶
ConditionalOrderedLogistic(domain: AnySpace, codomain: AnySpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional OrderedLogistic(predictor(x), cutpoints(x)).
The continuous input drives a parameter source that produces
1 + (K - 1) numbers: one real predictor and a K - 1 cutpoint
vector. The cutpoints are passed through a strictly-monotonic
transform (first entry free, subsequent entries via cumulative
softplus) so the cumulative-link contract c_0 < c_1 < ... <
c_{K-2} is satisfied unconditionally.
Outputs integer categories in {0, …, K - 1} where K =
codomain.size. The codomain must be a finite set.
Source code in src/quivers/continuous/families.py
1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 | |
ConditionalZeroInflatedPoisson
¶
ConditionalZeroInflatedPoisson(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional ZeroInflatedPoisson(zero_prob(x), rate(x)).
The parameter source produces 2 * codomain.dim numbers per
input row: the first half feeds a sigmoid to produce the
zero-inflation probability, the second half a softplus to
produce the Poisson rate. Outputs non-negative integer counts.
Source code in src/quivers/continuous/families.py
1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 | |
ConditionalHurdlePoisson
¶
ConditionalHurdlePoisson(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional HurdlePoisson(zero_prob(x), rate(x)).
Same parameter shape as ConditionalZeroInflatedPoisson but the
two-stage hurdle log-density: a Bernoulli for zero vs positive,
then a zero-truncated Poisson for the strictly-positive branch.
Source code in src/quivers/continuous/families.py
2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 | |
ConditionalZeroOneInflatedBeta
¶
ConditionalZeroOneInflatedBeta(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional ZeroOneInflatedBeta(mu(x), phi(x), zoi(x), coi(x)).
Parameter source emits 4 * dim numbers per row: logit-mu,
log-phi, logit-zoi, logit-coi. Used by the runtime family registry
for ~ ZeroOneInflatedBeta declarations; formula frontend
prefers the inline observe ... <- ZeroOneInflatedBeta(mu, phi, zoi, coi).
Source code in src/quivers/continuous/families.py
2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 | |
ConditionalMixtureNormal
¶
ConditionalMixtureNormal(domain: AnySpace, codomain: ContinuousSpace, num_components: int = 2, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional finite Gaussian mixture with input-driven weights, locations, and scales.
The parameter source produces 3 * K numbers per row, where
K is the number of mixture components (fixed at construction).
Weights pass through softmax, locations are emitted directly,
scales pass through softplus + epsilon.
The codomain is assumed scalar (1-d real); a higher-dimensional
extension would replace Normal with Independent(Normal(...), 1)
and triple the per-component parameter count.
Source code in src/quivers/continuous/families.py
2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 | |
ConditionalOneHotCategorical
¶
ConditionalOneHotCategorical(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional OneHotCategorical(probs(x)).
Generalises ConditionalCategorical to one-hot
encoded outputs (vector of zeros with a single one). Useful
as a discrete-output observation kernel where downstream
code wants a vector rather than an integer index.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space;
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 | |
ConditionalMixture
¶
ConditionalMixture(domain: AnySpace, codomain: ContinuousSpace, component_class: type, num_components: int = 4, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
K-component mixture of a conditional family.
Wraps a single conditional family class (one of the registered
ConditionalX types) and gives it K independent
parameterizations plus learnable mixture logits, producing
p(y | x) = sum_k pi_k(x) * f_k(y | x)
where each f_k is an instance of the component class and
pi is the softmax of K learnable logits.
Sampling is via ancestral simulation (Categorical pick + the
chosen component's rsample). log_prob evaluates the
log-sum-exp of the per-component log-densities. The Categorical
pick is non-reparameterizable; gradient flow through the
weights uses the score-function path (which higher-level
objectives like IWAE can route through).
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space; matches the component family's codomain.
TYPE:
|
component_class
|
A
TYPE:
|
num_components
|
Number of mixture components.
TYPE:
|
hidden_dim
|
Hidden width for both the mixture-logit MLP and each component's parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 | |
ConditionalIndependent
¶
ConditionalIndependent(base: ContinuousMorphism)
Bases: ContinuousMorphism
Reinterpret the trailing batch dimension of a base conditional family as an event dimension.
Equivalent to wrapping the base distribution in
torch.distributions.Independent with
reinterpreted_batch_ndims = 1. Used to make per-element
independence explicit when a downstream guide wants to score
a vector-valued observation as a single event.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The base conditional family. The wrapped distribution sums the base's per-element log-probabilities along the last axis to score a vector-valued observation.
TYPE:
|
Source code in src/quivers/continuous/families.py
2357 2358 2359 | |
ConditionalTransformed
¶
ConditionalTransformed(base: ContinuousMorphism, transforms: list)
Bases: ContinuousMorphism
A base conditional family composed with a chain of bijectors.
Equivalent to torch.distributions.TransformedDistribution
lifted to ContinuousMorphism. The transforms are applied in
forward order to rsample outputs; log_prob includes the
log-determinant Jacobian correction.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
Base conditional family.
TYPE:
|
transforms
|
Bijectors applied in forward order. Each must implement
TYPE:
|
Source code in src/quivers/continuous/families.py
2399 2400 2401 2402 2403 2404 2405 2406 | |
ConditionalLKJCholesky
¶
ConditionalLKJCholesky(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional LKJCholesky(dim, concentration(x)).
Produces lower-triangular Cholesky factors of correlation
matrices on the LKJ distribution (Lewandowski-Kurowicka-Joe
2009, doi:10.1016/j.jmva.2009.04.008). The matrix dimension
is taken from codomain.dim; only the concentration parameter
is learnable.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space;
TYPE:
|
hidden_dim
|
Hidden layer width for the parameter source.
TYPE:
|
Source code in src/quivers/continuous/families.py
2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 | |
ConditionalGaussianProcess
¶
ConditionalGaussianProcess(domain: AnySpace, codomain: ContinuousSpace, kernel: str = 'rbf', length_scale: float = 1.0, amplitude: float = 1.0, jitter: float = 1e-06)
Bases: ContinuousMorphism
Gaussian process prior with mean zero and a chosen covariance kernel.
A Gaussian process
is a Markov kernel X^N -> G(R^N) whose value at a finite set
of input locations x_1, ..., x_N follows a multivariate
Normal with covariance matrix K(x_i, x_j). Unlike the
parametric families that derive their distribution parameters
from a neural network on the input, the GP's "parameters" are
the input locations themselves: the kernel function evaluated
on the inputs produces the covariance directly.
Reference: Rasmussen & Williams (2006), Gaussian Processes for Machine Learning.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space. Its
TYPE:
|
codomain
|
Target space. Its
TYPE:
|
kernel
|
Covariance kernel.
TYPE:
|
length_scale
|
Initial length scale of the kernel (positive; learnable). Ignored by the linear kernel.
TYPE:
|
amplitude
|
Initial amplitude (positive; learnable). Multiplies the
kernel by
TYPE:
|
jitter
|
Diagonal regulariser added to
TYPE:
|
Source code in src/quivers/continuous/families.py
2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 | |
ConditionalHorseshoe
¶
ConditionalHorseshoe(domain: AnySpace, codomain: ContinuousSpace, scale: float = 1.0)
Bases: ContinuousMorphism
Carvalho-Polson-Scott horseshoe prior.
The horseshoe prior places a global-local shrinkage structure on each coordinate:
.. code-block:: text
tau ~ HalfCauchy(scale) lambda_d ~ HalfCauchy(1) for d = 1, ..., D beta_d | tau, lambda_d ~ Normal(0, (tau * lambda_d)^2)
The marginal density of beta_d after integrating the local
scale lambda_d has no closed form; this implementation uses a
16-point Gauss-Legendre quadrature after mapping the half-line
lambda in (0, inf) to t in (0, 1) via the change of
variables lambda = tan(pi * t / 2), whose Jacobian is
(pi / 2) * sec^2(pi * t / 2).
Reference: Carvalho, Polson & Scott (2010), The horseshoe estimator for sparse signals.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space. The prior is conditionally independent of
TYPE:
|
codomain
|
Target space. Its
TYPE:
|
scale
|
Initial global shrinkage
TYPE:
|
Source code in src/quivers/continuous/families.py
2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 | |
ConditionalGeneralizedPareto
¶
ConditionalGeneralizedPareto(domain: AnySpace, codomain: ContinuousSpace, hidden_dim: int | Sequence[int] | None = None, param_source: ParamSource | None = None, param_source_option: str | None = None)
Bases: ContinuousMorphism
Conditional generalized Pareto distribution.
| PARAMETER | DESCRIPTION |
|---|---|
domain
|
Source space.
TYPE:
|
codomain
|
Target space.
TYPE:
|
hidden_dim
|
Hidden widths, read only by a source that has hidden layers.
TYPE:
|
param_source
|
Select the parameter source directly, or by the DSL's
TYPE:
|
param_source_option
|
Select the parameter source directly, or by the DSL's
TYPE:
|
Source code in src/quivers/continuous/families.py
2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 | |
LKJCorrelationFactor
¶
LKJCorrelationFactor(dim: int, eta: float, domain: AnySpace)
Bases: ContinuousMorphism
LKJ prior on Cholesky factors LKJ(K, η) over CholeskyFactor(K).
Density on the Cholesky factor:
.. math::
p(L) \propto \prod_{k=2}^{K} L_{kk}^{K - k + 2(\eta - 1)}.
A higher concentration :math:\eta > 1 pulls toward the
identity correlation; :math:\eta = 1 is uniform on
correlations. Sampling uses the onion method of
Lewandowski-Kurowicka-Joe 2009: draw row-norm partial
correlations from Beta distributions and form :math:L
row-by-row.
| PARAMETER | DESCRIPTION |
|---|---|
dim
|
Correlation-matrix size :math:
TYPE:
|
eta
|
Concentration :math:
TYPE:
|
domain
|
The morphism's source (parameter conditioning); typically the program's input space. The LKJ prior itself does not consume per-observation conditioning, so the rsample path broadcasts the prior across the batch dimension.
TYPE:
|
Source code in src/quivers/continuous/families.py
3285 3286 3287 3288 3289 3290 3291 3292 3293 | |
log_prob
¶
log_prob(x: Tensor, y: Tensor) -> Tensor
Log-density of the LKJ prior at the Cholesky factor y.
Up to a normalizing constant that doesn't depend on
:math:L, :math:\log p(L) = \sum_{k=2}^{K} (K-k+2(\eta-1))
\log L_{kk}. The diagonal entries are extracted from the
flattened representation.
Source code in src/quivers/continuous/families.py
3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 | |
Truncated
¶
Truncated(base: ContinuousMorphism, lower: float | None = None, upper: float | None = None, max_rejection_iterations: int = 64)
Bases: ContinuousMorphism
Truncate a base family to an interval :math:[a, b].
Categorical denotation: given a base family
:math:F : \Theta \to \mathcal{G}(\mathbb{R}) and constants
:math:a, b \in \bar{\mathbb{R}} with :math:a < b, the
truncated family has density
.. math::
p_{F_{|[a,b]}}(x) = \frac{p_F(x)}{F_{\text{cdf}}(b)
- F_{\text{cdf}}(a)} \cdot \mathbb{1}_{[a,b]}(x)
and the morphism :math:F_{|[a,b]} : \Theta \to
\mathcal{G}([a,b]). Sampling uses inverse-CDF when
base supports it; otherwise rejection sampling.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The base distribution-family morphism. Must expose
TYPE:
|
lower
|
Lower bound :math:
TYPE:
|
upper
|
Upper bound :math:
TYPE:
|
max_rejection_iterations
|
Cap on rejection-sampling attempts before raising.
TYPE:
|
Source code in src/quivers/continuous/families.py
3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 | |