distrax
Distrax: Probability distributions in JAX.
What it is and what it does
Distrax is a JAX-native probability library that reimplements a subset of TensorFlow Probability with emphasis on readability and extensibility. It provides distributions (like MultivariateNormalDiag) and bijectors (invertible transformations with Jacobian tracking) that work seamlessly with JAX's functional and JIT-compilation paradigms. The library is designed to be cross-compatible with TensorFlow Probability—you can mix Distrax and TFP distributions in the same computation, or wrap one for use in the other's meta-distributions.
The package targets researchers and practitioners building probabilistic models, particularly in reinforcement learning where custom policy distributions are common. It emphasizes mathematical clarity in implementations and makes it simple to define custom distributions or bijectors. While not intended to replace TensorFlow Probability entirely, it fills the gap for teams already committed to JAX and wanting a lighter-weight, more extensible alternative for probability operations.
Use it for:
- Build probabilistic agent policies in reinforcement learning with custom distribution definitions.
- Sample from and compute log-probabilities of multivariate distributions in JAX-based machine learning pipelines.
- Compose complex distributions using bijectors (e.g., transformed distributions via Tanh or other invertible functions).
- Migrate TensorFlow Probability code to JAX by using Distrax distributions with cross-compatible APIs.
- Implement variational inference or other probabilistic inference methods using JAX's autodiff and JIT compilation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Distrax provides JAX-native probability distributions and bijectors (invertible functions with Jacobian computation) as a lightweight reimplementation of a subset of TensorFlow Probability, designed for extensibility and readability.
Yes. Distrax is actively maintained, has no known vulnerabilities, and offers a well-designed JAX-native alternative to TensorFlow Probability for teams already using JAX. The permissive Apache 2.0 license and cross-compatibility with TFP make it low-risk to adopt. Install it if you need probability distributions in JAX and value extensibility and mathematical clarity over a comprehensive feature set.
Install
distrax on PyPI
pip
pip install distraxuv
uv add distraxpoetry
poetry add distraxInstalling distrax
Before you install
Installation is straightforward with low friction; the package is actively maintained with a recent release and no known vulnerabilities. It depends on JAX, jaxlib, and TensorFlow Probability nightly, which are substantial but standard dependencies in the JAX ecosystem.
License in practice
Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution in commercial and private projects with minimal restrictions.
Quickstart
pip install distrax
import distrax
import jax
import jax.numpy as jnp
key = jax.random.PRNGKey(1234)
mu = jnp.array([-1., 0., 1.])
sigma = jnp.array([0.1, 0.2, 0.3])
dist = distrax.MultivariateNormalDiag(mu, sigma)
samples = dist.sample(seed=key)
log_prob = dist.log_prob(samples)
Requires Python >= 3.11 and a working JAX installation (including jaxlib, which may require a C++ compiler or prebuilt binaries for your platform).
Verify before relying
- Whether the library's API stability is guaranteed or if breaking changes are expected before a 1.0 release.
- Performance characteristics compared to TensorFlow Probability for common distributions and sampling operations.
- Coverage of which TFP distributions and bijectors are actually implemented in Distrax.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — absl-py, chex, jax, jaxlib, numpy, tfp-nightly |
| Maintenance | actively maintained — 63 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 188,525/month — #9,941 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: distrax-0.1.9-py3-none-any.whl
Keywords: jax, probability, distribution, python, machine learning
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
chexChex provides utilities for writing reliable…
permissive · top 5,000 on PyPI
tensorflow-probabilityTensorFlow Probability provides probabilistic…
permissive · top 5,000 on PyPI
jaxJAX is a Python library for automatic…
permissive · top 1,000 on PyPI
numpyroNumPyro is a probabilistic programming library…
permissive · top 15,000 on PyPI
jraphJraph provides data structures and utilities…
permissive · top 15,000 on PyPI
blackjaxBlackJAX provides a collection of MCMC and…
permissive · top 15,000 on PyPI
diffraxDiffrax provides numerical solvers for…
permissive · top 15,000 on PyPI
jax-cuda12-pjrtProvides NVIDIA GPU acceleration for JAX…
permissive · top 15,000 on PyPI
optaxOptax provides composable building blocks for…
permissive · top 5,000 on PyPI