| Attribute |
Value
|
| Sources |
pyro/distributions/__init__.py
|
| Domains |
Probabilistic Programming, Distribution Registry, Module Initialization
|
| Last Updated |
2026-02-09
|
Overview
Description
The pyro/distributions/__init__.py module serves as the central registry and public API entry point for all probability distributions available in Pyro. It aggregates distributions from three sources:
- PyTorch upstream distributions -- Re-exported from
pyro.distributions.torch, which wraps all of torch.distributions with Pyro-specific enhancements. These include standard distributions like Normal, Bernoulli, Beta, Categorical, Dirichlet, and many others.
- Pyro-native distributions -- Custom distributions implemented specifically for Pyro, covering specialized domains like directional statistics, hidden Markov models, coalescent processes, zero-inflated models, and heavy-tailed distributions.
- Infrastructure classes -- Foundational classes such as
TorchDistribution, Distribution, TransformModule, and utility functions for validation control.
The module applies a patch to PyTorch distributions (pyro.distributions.torch_patch) on import, then performs a wildcard import from the torch wrapper module, followed by explicit imports of all Pyro-native distributions. The final __all__ list is constructed by combining the Pyro-specific names with the torch distribution names, sorting and deduplicating the result.
Additionally, the module exports three submodules: constraints, kl (Kullback-Leibler divergences), and transforms.
Usage
Users typically import distributions from this top-level module: from pyro.distributions import Normal, Stable, SineSkewed. This single import path provides access to all available distributions regardless of whether they originate from PyTorch or are Pyro-native implementations.
Code Reference
Source Location
| Property |
Value
|
| File |
pyro/distributions/__init__.py
|
| Module |
pyro.distributions
|
| Repository |
pyro-ppl/pyro
|
Signature
# Core initialization pattern
import pyro.distributions.torch_patch # Apply PyTorch patches
from pyro.distributions.torch import * # Re-export all PyTorch distributions
# Explicit PyTorch distribution imports (for mypy)
from pyro.distributions.torch import (
Bernoulli, Beta, Binomial, Categorical, Cauchy, Chi2,
ContinuousBernoulli, Dirichlet, Exponential, ...
)
# Pyro-native distribution imports
from pyro.distributions.affine_beta import AffineBeta
from pyro.distributions.stable import Stable, StableWithLogProb
from pyro.distributions.unit import Unit
# ... (many more)
# Submodule exports
from . import constraints, kl, transforms
# Combined __all__ list
__all__ = [...] # 80+ distribution names, sorted and deduplicated
Import
# Standard user-facing import
import pyro.distributions as dist
# Or import specific distributions
from pyro.distributions import Normal, Stable, SineSkewed, Unit
I/O Contract
Exported PyTorch Distributions
| Distribution |
Description
|
Bernoulli |
Bernoulli distribution for binary outcomes
|
Beta |
Beta distribution on [0, 1]
|
Binomial |
Binomial distribution for count data
|
Categorical |
Categorical distribution over discrete categories
|
Cauchy |
Cauchy (Lorentz) distribution
|
Chi2 |
Chi-squared distribution
|
ContinuousBernoulli |
Continuous relaxation of Bernoulli
|
Dirichlet |
Dirichlet distribution over simplexes
|
Exponential |
Exponential distribution
|
FisherSnedecor |
F-distribution
|
Gamma |
Gamma distribution
|
Geometric |
Geometric distribution
|
Gumbel |
Gumbel (extreme value type I) distribution
|
HalfCauchy |
Half-Cauchy distribution
|
HalfNormal |
Half-Normal distribution
|
Independent |
Wraps a distribution to reinterpret batch dims as event dims
|
Kumaraswamy |
Kumaraswamy distribution on [0, 1]
|
Laplace |
Laplace distribution
|
LKJCholesky |
LKJ distribution on Cholesky factors of correlation matrices
|
LogisticNormal |
Logistic-Normal distribution
|
LogNormal |
Log-Normal distribution
|
LowRankMultivariateNormal |
Multivariate normal with low-rank plus diagonal covariance
|
MixtureSameFamily |
Mixture distribution with same family components
|
Multinomial |
Multinomial distribution
|
MultivariateNormal |
Multivariate normal distribution
|
NegativeBinomial |
Negative binomial distribution
|
Normal |
Normal (Gaussian) distribution
|
OneHotCategorical |
One-hot categorical distribution
|
OneHotCategoricalStraightThrough |
One-hot categorical with straight-through gradient
|
Pareto |
Pareto distribution
|
Poisson |
Poisson distribution
|
RelaxedBernoulli |
Relaxed (Gumbel-Softmax) Bernoulli distribution
|
RelaxedOneHotCategorical |
Relaxed (Gumbel-Softmax) categorical distribution
|
StudentT |
Student's t-distribution
|
TransformedDistribution |
Distribution formed by applying transforms
|
Uniform |
Uniform distribution
|
VonMises |
Von Mises distribution on the circle
|
Weibull |
Weibull distribution
|
Wishart |
Wishart distribution on positive-definite matrices
|
Exported Pyro-Native Distributions
| Distribution |
Source Module |
Description
|
AffineBeta |
affine_beta |
Beta distribution with affine transformation
|
AsymmetricLaplace |
asymmetriclaplace |
Asymmetric Laplace distribution
|
SoftAsymmetricLaplace |
asymmetriclaplace |
Smooth asymmetric Laplace distribution
|
AVFMultivariateNormal |
avf_mvn |
Auxiliary variational function multivariate normal
|
CoalescentRateLikelihood |
coalescent |
Coalescent rate likelihood
|
CoalescentTimes |
coalescent |
Distribution over coalescent times
|
CoalescentTimesWithRate |
coalescent |
Coalescent times with rate parameter
|
ConditionalDistribution |
conditional |
Base class for conditional distributions
|
ConditionalTransform |
conditional |
Conditional transform
|
ConditionalTransformedDistribution |
conditional |
Conditional transformed distribution
|
ConditionalTransformModule |
conditional |
Learnable conditional transform
|
BetaBinomial |
conjugate |
Beta-Binomial conjugate distribution
|
DirichletMultinomial |
conjugate |
Dirichlet-Multinomial conjugate distribution
|
GammaPoisson |
conjugate |
Gamma-Poisson (Negative Binomial) conjugate distribution
|
Delta |
delta |
Delta (point mass) distribution
|
MixtureOfDiagNormals |
diag_normal_mixture |
Mixture of diagonal normals
|
MixtureOfDiagNormalsSharedCovariance |
diag_normal_mixture_shared_cov |
Mixture of diagonal normals with shared covariance
|
Distribution |
distribution |
Pyro base distribution class
|
Empirical |
empirical |
Empirical distribution from samples
|
ExtendedBetaBinomial |
extended |
Extended Beta-Binomial distribution
|
ExtendedBinomial |
extended |
Extended Binomial distribution
|
FoldedDistribution |
folded |
Folded (absolute value) distribution
|
GaussianScaleMixture |
gaussian_scale_mixture |
Gaussian scale mixture distribution
|
GroupedNormalNormal |
grouped_normal_normal |
Grouped Normal-Normal model
|
DiscreteHMM |
hmm |
Discrete Hidden Markov Model
|
GammaGaussianHMM |
hmm |
Gamma-Gaussian HMM
|
GaussianHMM |
hmm |
Gaussian HMM
|
GaussianMRF |
hmm |
Gaussian Markov Random Field
|
IndependentHMM |
hmm |
Independent HMM
|
LinearHMM |
hmm |
Linear HMM
|
ImproperUniform |
improper_uniform |
Improper uniform distribution
|
InverseGamma |
inverse_gamma |
Inverse gamma distribution (Pyro fallback if not in PyTorch)
|
LKJ |
lkj |
LKJ distribution on correlation matrices
|
LKJCorrCholesky |
lkj |
LKJ on Cholesky factors of correlation matrices
|
LogNormalNegativeBinomial |
log_normal_negative_binomial |
Log-Normal Negative Binomial
|
Logistic |
logistic |
Logistic distribution
|
SkewLogistic |
logistic |
Skew logistic distribution
|
MaskedMixture |
mixture |
Masked mixture of two distributions
|
MultivariateStudentT |
multivariate_studentt |
Multivariate Student's t-distribution
|
NanMaskedMultivariateNormal |
nanmasked |
NaN-masked multivariate normal
|
NanMaskedNormal |
nanmasked |
NaN-masked normal
|
OMTMultivariateNormal |
omt_mvn |
Orthogonal Monte Carlo multivariate normal
|
OneOneMatching |
one_one_matching |
One-to-one matching distribution
|
OneTwoMatching |
one_two_matching |
One-to-two matching distribution
|
OrderedLogistic |
ordered_logistic |
Ordered logistic distribution
|
TruncatedPolyaGamma |
polya_gamma |
Truncated Polya-Gamma distribution
|
ProjectedNormal |
projected_normal |
Projected normal distribution on the sphere
|
Rejector |
rejector |
Rejection sampling distribution
|
RelaxedBernoulliStraightThrough |
relaxed_straight_through |
Relaxed Bernoulli with straight-through gradient
|
RelaxedOneHotCategoricalStraightThrough |
relaxed_straight_through |
Relaxed one-hot categorical with straight-through gradient
|
SineBivariateVonMises |
sine_bivariate_von_mises |
Sine bivariate von Mises distribution
|
SineSkewed |
sine_skewed |
Sine-skewed torus distribution
|
SoftLaplace |
softlaplace |
Smooth Laplace-like distribution
|
SpanningTree |
spanning_tree |
Distribution over spanning trees
|
Stable |
stable |
Levy alpha-stable distribution
|
StableWithLogProb |
stable |
Stable distribution without automatic reparameterization
|
VonMises3D |
von_mises_3d |
Von Mises-Fisher distribution in 3D
|
ZeroInflatedDistribution |
zero_inflated |
Zero-inflated wrapper distribution
|
ZeroInflatedNegativeBinomial |
zero_inflated |
Zero-inflated negative binomial
|
ZeroInflatedPoisson |
zero_inflated |
Zero-inflated Poisson
|
Exported Infrastructure Classes
| Name |
Source Module |
Description
|
TorchDistribution |
torch_distribution |
Base class for Pyro-compatible distributions wrapping PyTorch
|
ExpandedDistribution |
torch_distribution |
Distribution with expanded batch dimensions
|
MaskedDistribution |
torch_distribution |
Distribution with masked log_prob
|
TransformModule |
torch_transform |
Base class for learnable transforms (nn.Module + Transform)
|
ComposeTransformModule |
torch_transform |
Composition of learnable transforms
|
Unit |
unit |
Trivial distribution for pyro.factor statements
|
Exported Utilities
| Name |
Description
|
enable_validation |
Enable or disable distribution argument validation globally
|
is_validation_enabled |
Check whether validation is currently enabled
|
validation_enabled |
Context manager for temporarily enabling/disabling validation
|
Exported Submodules
| Submodule |
Description
|
constraints |
Pyro-specific distribution constraints (extends PyTorch constraints)
|
kl |
Kullback-Leibler divergence implementations for Pyro distributions
|
transforms |
Distribution transforms including normalizing flow components
|
Usage Examples
Importing Distributions
# Recommended: import the module as dist
import pyro.distributions as dist
# Use PyTorch distributions seamlessly
normal = dist.Normal(0.0, 1.0)
beta = dist.Beta(2.0, 5.0)
# Use Pyro-native distributions the same way
stable = dist.Stable(stability=1.5, skew=0.3)
soft_laplace = dist.SoftLaplace(loc=0.0, scale=1.0)
Importing Specific Distributions
from pyro.distributions import (
Normal,
Stable,
SineSkewed,
SineBivariateVonMises,
Unit,
TransformModule,
)
Using Constraints and Transforms
import pyro.distributions as dist
# Access the constraints submodule
positive_constraint = dist.constraints.positive
simplex_constraint = dist.constraints.simplex
# Access the transforms submodule
exp_transform = dist.transforms.ExpTransform()
Validation Control
import pyro.distributions as dist
# Enable validation globally
dist.enable_validation(True)
print(dist.is_validation_enabled()) # True
# Use context manager for temporary validation
with dist.validation_enabled(False):
# Validation disabled in this block
d = dist.Normal(0.0, -1.0) # Would normally raise
dist.enable_validation(False)
Listing All Available Distributions
import pyro.distributions as dist
# Print all exported names
for name in sorted(dist.__all__):
print(name)
Related Pages
- RelaxedStraightThrough -- Straight-through gradient variants of relaxed discrete distributions
- SineSkewed -- Sine-skewed torus distributions for directional statistics
- SoftLaplace -- Smooth Laplace-like distribution
- Stable -- Levy alpha-stable distribution family
- TransformModule -- Base class for learnable distribution transforms
- Unit -- Trivial distribution for factor statements