Composite and joint¶
Distributions combining named components into a joint over a
Record. Component access: dist["name"] returns a view
(see Internals for the correlation semantics);
dist.select("x", "y") splats into a workflow function.
ProductDistribution(*positional, name=None, **components)
¶
Bases: RecordDistribution, SupportsSampling, SupportsConditioning
Joint distribution with independent leaf components.
Inherits from RecordDistribution. All leaf components are
sampled independently. _sample() returns Record.
Dynamic protocol support: SupportsLogProb, SupportsMean,
and SupportsVariance are included only when ALL leaf components
support them. isinstance(product, SupportsLogProb) is True
only when every component has _log_prob.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*positional
|
NumericRecordDistribution
|
Named distributions. Each distribution's |
()
|
name
|
str
|
Distribution name for the joint. |
None
|
**components
|
NumericRecordDistribution or dict
|
Named independent component distributions. Values may be
|
{}
|
Examples:
::
# Positional — uses each distribution's name as the key:
ProductDistribution(Normal(0, 1, name="x"), Gamma(2, 1, name="y"))
# Keyword — auto-renames if the key differs:
ProductDistribution(growth_rate=Normal(0, 1, name="x"))
# Mixed:
ProductDistribution(Normal(0, 1, name="x"), scale=Gamma(2, 1, name="y"))
Source code in probpipe/distributions/_product.py
components
property
¶
Read-only view of the component distributions.
SequentialJointDistribution(*, name=None, **components)
¶
Bases: RecordDistribution, SupportsSampling, SupportsConditioning
Joint distribution with autoregressive (sequential) dependence.
Components can be Distribution instances (roots) or callables
that receive previously-sampled values and return a Distribution
(conditionals).
Example::
joint = SequentialJointDistribution(
z=Normal(loc=0.0, scale=1.0, name="z"),
x=lambda z: Normal(loc=z, scale=0.5, name="x"),
y=lambda z, x: Normal(loc=z + x, scale=0.1, name="y"),
)
Callable signatures are inspected: parameter names must match earlier component names.
Dynamic protocol support: SupportsLogProb / SupportsMean
/ SupportsVariance are included only when every resolved leaf
component supports them. Sampling and conditioning are always
available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Distribution name. |
None
|
**components
|
Distribution or Callable[..., Distribution]
|
Named components in topological (dependency) order. |
{}
|
Source code in probpipe/distributions/_sequential_joint.py
TransformedDistribution(base, bijector, *, name=None)
¶
Bases: NumericRecordDistribution
Distribution formed by applying a TFP bijector to a base distribution.
When base is a TFPDistribution, sampling and density
evaluation delegate to tfd.TransformedDistribution for maximum
efficiency. Otherwise (e.g. EmpiricalDistribution), the
bijector's forward / inverse / inverse_log_det_jacobian
are applied manually.
Dynamic protocol support: SupportsLogProb, SupportsMean,
and SupportsVariance are included only when the base distribution
supports them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
Distribution
|
The untransformed base distribution. |
required |
bijector
|
Bijector
|
A TFP bijector (e.g. |
required |
name
|
str
|
Distribution name for provenance. |
None
|
Source code in probpipe/distributions/transformed.py
base
property
¶
The untransformed base distribution.
bijector
property
¶
The TFP bijector applied to base.
dtypes
property
¶
Per-field dtype — derived from the transformed TFP distribution when available, falling back to the base distribution's dtype. Spread across the auto-built single-field template.
support
property
¶
Derive the output support from the bijector when possible.
The bijector
machinery pairs naturally with TransformedDistribution for
unconstrained-to-constrained reparameterization.
JointGaussian(*, mean, cov, name=None, **component_shapes)
¶
Bases: RecordDistribution, SupportsSampling, SupportsLogProb, SupportsMean, SupportsVariance, SupportsCovariance, SupportsConditioning
Joint Gaussian distribution with named components and cross-covariance.
Supports exact analytical conditioning via condition_on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
array-like, shape ``(d,)``
|
Full (flat) mean vector. |
required |
cov
|
array-like, shape ``(d, d)``
|
Full (flat) covariance matrix. |
required |
name
|
str
|
Distribution name. |
None
|
**component_shapes
|
int
|
Named components with their dimensionality. The sum of all
dimensions must equal |
{}
|
Examples:
>>> joint = JointGaussian(
... mean=jnp.array([0.0, 0.0, 1.0, 2.0]),
... cov=jnp.eye(4),
... x=1, # x is 1-dimensional
... yz=3, # yz is 3-dimensional
... )